You are here

public function OutputFormatterStyle::setForeground in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Formatter/OutputFormatterStyle.php \Symfony\Component\Console\Formatter\OutputFormatterStyle::setForeground()

Sets style foreground color.

Parameters

string|null $color The color name:

Throws

\InvalidArgumentException When the color name isn't defined

Overrides OutputFormatterStyleInterface::setForeground

1 call to OutputFormatterStyle::setForeground()
OutputFormatterStyle::__construct in vendor/symfony/console/Formatter/OutputFormatterStyle.php
Initializes output formatter style.

File

vendor/symfony/console/Formatter/OutputFormatterStyle.php, line 82

Class

OutputFormatterStyle
Formatter style class for defining styles.

Namespace

Symfony\Component\Console\Formatter

Code

public function setForeground($color = null) {
  if (null === $color) {
    $this->foreground = null;
    return;
  }
  if (!isset(static::$availableForegroundColors[$color])) {
    throw new \InvalidArgumentException(sprintf('Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors))));
  }
  $this->foreground = static::$availableForegroundColors[$color];
}