Exemplo n.º 1
0
 /**
  * @dataProvider fromRGBProvider
  **/
 public function testFromRGB($aRGB, $aExpectedColor, $aExpectedDescription)
 {
     $oColor = new CSSColor();
     $oColor->fromRGB($aRGB);
     $this->assertEquals($oColor->getColor(), $aExpectedColor);
     $this->assertEquals($oColor->getColorDescription(), $aExpectedDescription);
 }
Exemplo n.º 2
0
 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;
 }