/** * @dataProvider normalizeRGBValueProvider **/ public function testNormalizeRGBValue($mValue, $fExcpected) { $fResult = CSSColorUtils::normalizeRGBValue($mValue); $this->assertEquals($fResult, $fExcpected); }
public function fromRGB(array $aRGB) { $this->aComponents = array(); $sName = 'rgb'; foreach (array('r', 'g', 'b', 'a') as $sChannel) { if ($sChannel == 'a') { if (!isset($aRGB['a'])) { continue; } $sValue = CSSColorUtils::constrainValue((string) $aRGB['a'], 0, 1); if ($sValue == 1) { continue; } $sName .= 'a'; } else { $sValue = CSSColorUtils::normalizeRGBValue((string) $aRGB[$sChannel]); } $this->aComponents[$sChannel] = new CSSSize($sValue, null, true); } $this->setName($sName); return $this; }