1 | <?php |
||
5 | class HexColorPair |
||
6 | { |
||
7 | const MIN_RATIO = 3.0; |
||
8 | const MAX_RATIO = 4.5; // hard cap on the max requested ratio, to mitigate performance issues |
||
9 | |||
10 | public $ratio; // computed contrast ratio between fg : bg |
||
11 | |||
12 | // Calling these foreground/background instead of a more generic "color 1"/"color 2" |
||
13 | // Doesn't really matter, they can be used interchangeably |
||
14 | public $fg; // foreground (text) color |
||
15 | public $bg; // background color |
||
16 | |||
17 | protected $minRatio; |
||
18 | |||
19 | public function __construct(HexColor $fg = null, HexColor $bg = null) |
||
25 | |||
26 | public static function make(HexColor $fg, HexColor $bg) |
||
30 | |||
31 | public static function ratio(HexColor $fg, HexColor $bg) |
||
35 | |||
36 | public static function random(): self |
||
40 | |||
41 | public static function sibling(string $hexValue): HexColor |
||
45 | |||
46 | public static function minContrast($ratio): self |
||
61 | |||
62 | public function getRandom(): self |
||
70 | |||
71 | public function getSibling(string $hexValue): HexColor |
||
79 | |||
80 | protected static function calculateRatio(HexColor $fg = null, HexColor $bg = null) |
||
91 | |||
92 | protected static function luminance(HexColor $color) |
||
113 | |||
114 | /** |
||
115 | * '#abcdef' => ['ab', 'cd', 'ef']. |
||
116 | */ |
||
117 | protected static function rgbHexChannels(HexColor $hexColor): array |
||
127 | |||
128 | protected function getRandomPairMinRatio($fg, $minRatio): self |
||
137 | } |
||
138 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.