/** * @param $string * @return static * @throws InvalidColorNameException */ public static function fromString($string) { if (!($hex = ColorList::getHexFromName($string))) { throw new InvalidColorNameException($string); } return new static($hex); }
public function testGetHexFromName() { $this->assertEquals('FF0000', ColorList::getHexFromName('Red')); $this->assertEquals('FF0000', ColorList::getHexFromName('red')); }