Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Console] added ability to add custom colors#19844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -74,6 +74,66 @@ public function __construct($foreground = null, $background = null, array $optio | ||
| } | ||
| } | ||
| /** | ||
| * Add additional foreground color option. | ||
| * | ||
| * @param string $name The color name | ||
| * @param string|int $color The color code | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
| ||
| * @param string|int $unset The unset color code | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more.
| ||
| * | ||
| * @throws InvalidArgumentException When the color name is already defined | ||
| */ | ||
| public static function addForegroundColor($name, $value, $unset = 0) | ||
| { | ||
| static::addColor('foreground', $name, (int) $value, (int) $unset); | ||
| } | ||
| /** | ||
| * Add additional background color option. | ||
| * | ||
| * @param string $name The color name | ||
| * @param string|int $color The color code | ||
| * @param string|int $unset The unset color code | ||
| * | ||
| * @throws InvalidArgumentException When the color name is already defined | ||
| */ | ||
| public static function addBackgroundColor($name, $value, $unset = 0) | ||
| { | ||
| static::addColor('background', $name, (int) $value, (int) $unset); | ||
| } | ||
| /** | ||
| * Add additional color option. | ||
| * | ||
| * @param string $color The color type | ||
| * @param int $color The color code | ||
| * @param int $unset The unset color code | ||
| * | ||
| * @throws InvalidArgumentException When the color name is already defined | ||
| */ | ||
| private static function addColor($type, $name, $value, $unset) | ||
| { | ||
| $property = 'available'.ucfirst($type).'Colors'; | ||
| if (isset(static::${$property}[$name])) { | ||
| throw new InvalidArgumentException(sprintf( | ||
| 'The specified %s color "%s" is already defined. Expected a different name than (%s)', | ||
| $type, | ||
| $name, | ||
| implode(', ', array_keys(static::${$property})) | ||
| )); | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. should be on one line | ||
| } | ||
| if ($unset === 0) { | ||
| $unset = static::${$property}['default']['set']; | ||
| } | ||
| static::${$property}[$name] = array( | ||
| 'set' => $value, | ||
| 'unset' => $unset, | ||
| ); | ||
| } | ||
| /** | ||
| * Sets style foreground color. | ||
| * | ||