|
16 | 16 | * Class Style |
17 | 17 | * @package Inhere\Console\Style |
18 | 18 | * @link https://github.com/ventoviro/windwalker-IO |
| 19 | + * |
| 20 | + * @method string info(string $message) |
| 21 | + * @method string comment(string $message) |
| 22 | + * @method string success(string $message) |
| 23 | + * @method string warning(string $message) |
| 24 | + * @method string danger(string $message) |
| 25 | + * @method string error(string $message) |
19 | 26 | */ |
20 | 27 | class Style |
21 | 28 | { |
@@ -95,6 +102,21 @@ public function __construct($fg = '', $bg = '', array $options = []) |
95 | 102 | $this->loadDefaultStyles(); |
96 | 103 | } |
97 | 104 |
|
| 105 | + /** |
| 106 | + * @param string $method |
| 107 | + * @param array $args |
| 108 | + * @return mixed|string |
| 109 | + * @throws \InvalidArgumentException |
| 110 | + */ |
| 111 | + public function __call($method, array $args) |
| 112 | + { |
| 113 | + if (isset($args[0]) && $this->hasStyle($method)) { |
| 114 | + return $this->format(sprintf('<%s>%s</%s>', $method, $args[0], $method)); |
| 115 | + } |
| 116 | + |
| 117 | + throw new \InvalidArgumentException("You called method is not exists: $method"); |
| 118 | + } |
| 119 | + |
98 | 120 | /** |
99 | 121 | * Adds predefined color styles to the Color styles |
100 | 122 | * default primary success info warning danger |
@@ -193,7 +215,9 @@ public static function stripColor($string) |
193 | 215 | return preg_replace(self::STRIP_TAG, '', $string); |
194 | 216 | } |
195 | 217 |
|
196 | | -///////////////////////////////////////// Attr Color Style ///////////////////////////////////////// |
| 218 | + /**************************************************************************** |
| 219 | + * Attr Color Style |
| 220 | + ****************************************************************************/ |
197 | 221 |
|
198 | 222 | /** |
199 | 223 | * Add a style. |
|
0 commit comments