Skip to content

Commit

Permalink
some update, some waring fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Jun 19, 2017
1 parent 98079d4 commit e46a45e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
3 changes: 2 additions & 1 deletion README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
- 颜色风格输出支持
- 特殊格式信息显示
- 用户信息交互支持
- 其他功能

## 项目地址

- **git@osc** https://git.oschina.net/inhere/php-console.git
- **github** https://github.com/inhere/php-console.git
- **git@osc** https://git.oschina.net/inhere/php-console.git

## 安装

Expand Down
2 changes: 1 addition & 1 deletion src/AbstractApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function config($name, $default = null)
if (strpos($name, '.') > 1) {
[$topKey, $subKey] = explode('.', $name, 2);

if (isset($this->config[$topKey]) && isset($this->config[$topKey][$subKey])) {
if (isset($this->config[$topKey], $this->config[$topKey][$subKey])) {
return $this->config[$topKey][$subKey];
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/io/InputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@

namespace inhere\console\io;

use inhere\console\Helper;
use inhere\console\style\Style;
use inhere\console\utils\Interact;

/**
* Class Input
* @package inhere\console\io
Expand Down
4 changes: 0 additions & 4 deletions src/io/OutputInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@

namespace inhere\console\io;

use inhere\console\Helper;
use inhere\console\style\Style;
use inhere\console\utils\Interact;

/**
* Class OutputInterface
* @package inhere\console\io
Expand Down
12 changes: 8 additions & 4 deletions src/style/LiteStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,20 @@ public static function add($text, $style = self::NORMAL)
{
return self::render($text, $style);
}

/**
* @param $text
* @param string|int|array $style
* @return string
*/
public static function render($text, $style = self::NORMAL)
{
if (!Helper::isSupportColor()) {
return $text;
}

if(is_string($style)) {
$out = isset(self::$styles[$style]) ? self::$styles[$style] : self::NORMAL;
$out = self::$styles[$style] ?? self::NORMAL;
} elseif (is_int($style)) {
$out = $style;

Expand All @@ -98,9 +104,7 @@ public static function render($text, $style = self::NORMAL)
}

// $result = chr(27). "$out{$text}" . chr(27) . chr(27) . "[0m". chr(27);
$result = "\033[{$out}m{$text}\033[0m";

return $result;
return "\033[{$out}m{$text}\033[0m";
}

/**
Expand Down

0 comments on commit e46a45e

Please sign in to comment.