/** * @dataProvider fromRGBProvider **/ public function testFromRGB($aRGB, $aExpectedColor, $aExpectedDescription) { $oColor = new CSSColor(); $oColor->fromRGB($aRGB); $this->assertEquals($oColor->getColor(), $aExpectedColor); $this->assertEquals($oColor->getColorDescription(), $aExpectedDescription); }
private function parseIdentifier($bAllowFunctions = false, $bAllowColors = false) { $sResult = $this->parseCharacter(true); if ($sResult === null) { throw new Exception("Identifier expected, got {$this->peek(5)}"); } $sCharacter; while (($sCharacter = $this->parseCharacter(true)) !== null) { $sResult .= $sCharacter; } if ($bAllowColors) { // is it a color name ? if ($aColor = CSSColorUtils::namedColor2rgb($sResult)) { $oColor = new CSSColor(); return $oColor->fromRGB($aColor); } } if ($bAllowFunctions && $this->comes('(')) { $this->consume('('); $sResult = new CSSFunction($sResult, $this->parseValue(array('=', ','))); $this->consume(')'); } return $sResult; }