|
@@ 76-89 (lines=14) @@
|
| 73 |
|
* @throws \InvalidArgumentException |
| 74 |
|
* @api |
| 75 |
|
*/ |
| 76 |
|
public function setForeground($color = null) |
| 77 |
|
{ |
| 78 |
|
if (null === $color) { |
| 79 |
|
$this->foreground = null; |
| 80 |
|
|
| 81 |
|
return; |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
if (!isset(static::$availableForegroundColors[$color])) { |
| 85 |
|
throw new \InvalidArgumentException(sprintf('Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors)))); |
| 86 |
|
} |
| 87 |
|
|
| 88 |
|
$this->foreground = static::$availableForegroundColors[$color]; |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
/** |
| 92 |
|
* 设置背景色 |
|
@@ 97-110 (lines=14) @@
|
| 94 |
|
* @throws \InvalidArgumentException |
| 95 |
|
* @api |
| 96 |
|
*/ |
| 97 |
|
public function setBackground($color = null) |
| 98 |
|
{ |
| 99 |
|
if (null === $color) { |
| 100 |
|
$this->background = null; |
| 101 |
|
|
| 102 |
|
return; |
| 103 |
|
} |
| 104 |
|
|
| 105 |
|
if (!isset(static::$availableBackgroundColors[$color])) { |
| 106 |
|
throw new \InvalidArgumentException(sprintf('Invalid background color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableBackgroundColors)))); |
| 107 |
|
} |
| 108 |
|
|
| 109 |
|
$this->background = static::$availableBackgroundColors[$color]; |
| 110 |
|
} |
| 111 |
|
|
| 112 |
|
/** |
| 113 |
|
* 设置字体格式 |