/** * 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(); }
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 = "[5m[1m[41m[33mtest TextElement[0m[0m[0m[0m"; $this->string($output)->isEqualTo($expectedString); }