Example #1
0
 /**
  * Static calls interface to allow calls such as green('hello');
  */
 public static function __callstatic($name, $params)
 {
     $knownColors = static::getKnownColors();
     $colorID = $knownColors[$name];
     $color = static::color($colorID);
     // target string is expected to be:
     $targetString = $params[0][0];
     $element = new TextElement($targetString);
     $element->setTextColor($color);
     return $element->render();
 }
Example #2
0
 /**
  * Static calls interface
  */
 public static function __callstatic($name, $params)
 {
     $knownStyles = static::getKnownStyles();
     $styleID = $knownStyles[$name];
     $style = static::style($styleID);
     // target string is expected to be:
     $targetString = $params[0][0];
     $element = new TextElement($targetString);
     $element->addStyle($style);
     return $element->render();
 }
Example #3
0
 public function testRender()
 {
     $textElement = new Output\TextElement('test TextElement');
     $style1 = new Mock\Matks\Vivian\Style\Style(1);
     $style2 = new Mock\Matks\Vivian\Style\Style(5);
     $textColor = new Mock\Matks\Vivian\Color\TextColor(33);
     $bgColor = new Mock\Matks\Vivian\Color\BackgroundColor(41);
     $textElement->setTextColor($textColor)->setBackgroundColor($bgColor)->addStyle($style1)->addStyle($style2);
     $output = $textElement->render();
     $expectedString = "test TextElement";
     $this->string($output)->isEqualTo($expectedString);
 }
Example #4
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();
 }
Example #5
0
 /**
  * Render bordered element
  *
  * @return string
  */
 public function render()
 {
     $text = parent::render();
     $borderedText = BorderManager::buildBorder($text, $this->border);
     return $borderedText;
 }