1 | <?php |
||
5 | class HexColor implements Color |
||
6 | { |
||
7 | public $hex; |
||
8 | public $name; |
||
9 | |||
10 | public function __construct(string $hex, string $name = null) |
||
15 | |||
16 | public static function make(string $hex, string $name = null): self |
||
20 | |||
21 | public static function random(): self |
||
25 | |||
26 | /** |
||
27 | * '#abc' or 'abc' => '#aabbcc' |
||
28 | * '#abcdef' or 'abcdef' => '#abcdef'. |
||
29 | */ |
||
30 | protected function normalize(string $hexColor) |
||
45 | |||
46 | /** |
||
47 | * @see https://stackoverflow.com/questions/5614530/generating-a-random-hex-color-code-with-php |
||
48 | */ |
||
49 | protected static function randomColor() |
||
53 | |||
54 | protected static function randomColorPart() |
||
58 | } |
||
59 |