Пример #1
0
 public function testSetBackgroundColor()
 {
     $textElement = new Output\TextElement('test TextElement');
     $color1 = new Mock\Matks\Vivian\Color\BackgroundColor(43);
     $textElement->setBackgroundColor($color1);
     $this->object($textElement->getBackgroundColor())->isEqualTo($color1);
     $color2 = new Mock\Matks\Vivian\Color\BackgroundColor(47);
     $textElement->setBackgroundColor($color2);
     $this->object($textElement->getBackgroundColor())->isEqualTo($color2);
 }
Пример #2
0
 /**
  * Static calls interface to allow calls such as back_green('hello');
  */
 public static function __callstatic($name, $params)
 {
     $matches = static::isBackgroundCall($name);
     if (null === $matches) {
         throw new Exception("Unknown background color function name {$name}");
     }
     $colorName = $matches[2];
     $knownColors = static::getKnownColors();
     $colorID = $knownColors[$colorName];
     if (!$colorID) {
         throw new Exception("Unknown background color name {$name}");
     }
     $color = static::color($colorID);
     // target string is expected to be:
     $targetString = $params[0][0];
     $element = new TextElement($targetString);
     $element->setBackgroundColor($color);
     return $element->render();
 }