Skip to content

Commit

Permalink
feat (factory): add cmyk
Browse files Browse the repository at this point in the history
  • Loading branch information
NikarashiHatsu committed Oct 3, 2023
1 parent d73f70f commit 2d2a700
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Color/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ public static function init(string $color): BaseColor
{
$color = str_replace(' ', '', $color);
// Definitive types
if (preg_match('/^(?P<type>(rgba?|hsla?|hsv))/i', $color, $match)) {
if (preg_match('/^(?P<type>(rgba?|hsla?|hsv|cmyk))/i', $color, $match)) {
$class = self::resolveClass($match['type']);
return new $class($color);
}
// Best guess
if (preg_match('/^\d{1,3},\d{1,3},\d{1,3},\d{1,3}[^.]$/', $color)) {
return new Cmyk($color);
}
if (preg_match('/^#?[a-f0-9]{8}$/i', $color)) {
return new Hexa($color);
}
Expand Down

0 comments on commit 2d2a700

Please sign in to comment.