You are here

public function OutputFormatterStyle::setBackground 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::setBackground()

Sets style background color.

Parameters

string|null $color The color name:

Throws

\InvalidArgumentException When the color name isn't defined

Overrides OutputFormatterStyleInterface::setBackground

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

File

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

Class

OutputFormatterStyle
Formatter style class for defining styles.

Namespace

Symfony\Component\Console\Formatter

Code

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