public static toHex ( Pop\Color\Space\ColorInterface $color ) : |
||
$color | Pop\Color\Space\ColorInterface | |
리턴 |
public static function toHex(Space\ColorInterface $color)
{
$class = get_class($color);
if ($class == 'Pop\\Color\\Space\\Hex') {
throw new Exception('That color space object is already that type.');
}
$type = strtolower(substr($class, strrpos($class, '\\') + 1));
$method = $type . 'ToHex';
return self::$method($color);
}
public function testLabToHex() { $hex = Convert::toHex(new Lab(100, 100, 100)); $this->assertInstanceOf('Pop\\Color\\Space\\Hex', $hex); $this->assertEquals('#c39231', (string) $hex); }