1 | <?php |
||
15 | class yiq_scheme extends scheme { |
||
16 | |||
17 | /** |
||
18 | * A static reference to this class. (important for late static binding) |
||
19 | * @var string |
||
20 | */ |
||
21 | protected static $this_class = __CLASS__; |
||
22 | |||
23 | /** |
||
24 | * These colors are all close to each other on a color wheel. |
||
25 | * |
||
26 | * @param float $h The base color hue degree (0 - 359) |
||
27 | * @param float $s The base color saturation percentage (0 - 100) |
||
28 | * @param float $l The base color lighting percentage (0 - 100) |
||
29 | * @param bool|null $is_dark Whether or not to treat the base color as a dark color. Leave as null to dynamically generate this. |
||
30 | * @return array An array of 5 analogous colors where the first offset is the original input. |
||
31 | */ |
||
32 | 1 | public static function analogous_set (float $h = 0.0, float $s = 0.0, float $l = 0.0, $is_dark = NULL) :array { |
|
35 | |||
36 | /** |
||
37 | * 2 of these colors are a different shade of the base color. The other 2 are |
||
38 | * a weighted opposite of the base color. |
||
39 | * |
||
40 | * @param float $h The base color hue degree (0 - 359) |
||
41 | * @param float $s The base color saturation percentage (0 - 100) |
||
42 | * @param float $l The base color lighting percentage (0 - 100) |
||
43 | * @param bool|null $is_dark Whether or not to treat the base color as a dark color. Leave as null to dynamically generate this. |
||
44 | * @return array An array of 5 complementary colors where the first offset is the original input. |
||
45 | */ |
||
46 | 1 | public static function complementary_set (float $h = 0.0, float $s = 0.0, float $l = 0.0, $is_dark = NULL) :array { |
|
49 | |||
50 | /** |
||
51 | * These colors use mathematical offsets that usually complement each other |
||
52 | * well, and can highlight the base color. |
||
53 | * |
||
54 | * @param float $h The base color hue degree (0 - 359) |
||
55 | * @param float $s The base color saturation percentage (0 - 100) |
||
56 | * @param float $l The base color lighting percentage (0 - 100) |
||
57 | * @param bool|null $is_dark Whether or not to treat the base color as a dark color. Leave as null to dynamically generate this. |
||
58 | * @return array An array of 5 compounding colors where the first offset is the original input. |
||
59 | */ |
||
60 | 1 | public static function compound_set (float $h = 0.0, float $s = 0.0, float $l = 0.0, $is_dark = NULL) :array { |
|
63 | |||
64 | /** |
||
65 | * 5 complementary shades of one color. |
||
66 | * |
||
67 | * @param float $h The base color hue degree (0 - 359) |
||
68 | * @param float $s The base color saturation percentage (0 - 100) |
||
69 | * @param float $l The base color lighting percentage (0 - 100) |
||
70 | * @param bool|null $is_dark Whether or not to treat the base color as a dark color. Leave as null to dynamically generate this. |
||
71 | * @return array An array of 5 complementary shades of colors where the first offset is the original input. |
||
72 | */ |
||
73 | 1 | public static function monochromatic_set (float $h = 0.0, float $s = 0.0, float $l = 0.0, $is_dark = NULL) :array { |
|
76 | |||
77 | /** |
||
78 | * 5 different shades of one color. |
||
79 | * |
||
80 | * @param float $h The base color hue degree (0 - 359) |
||
81 | * @param float $s The base color saturation percentage (0 - 100) |
||
82 | * @param float $l The base color lighting percentage (0 - 100) |
||
83 | * @param bool|null $is_dark Whether or not to treat the base color as a dark color. Leave as null to dynamically generate this. |
||
84 | * @return array An array of 5 shades of a color where the first offset is the original input. |
||
85 | */ |
||
86 | 6 | public static function shades_set (float $h = 0.0, float $s = 0.0, float $l = 0.0, $is_dark = NULL) :array { |
|
89 | |||
90 | /** |
||
91 | * 3 of these colors are all equally distanced from each other on a color |
||
92 | * wheel, plus 1 alternated shade for the base color and the 1 color that is |
||
93 | * opposite of the base color. |
||
94 | * |
||
95 | * @param float $h The base color hue degree (0 - 359) |
||
96 | * @param float $s The base color saturation percentage (0 - 100) |
||
97 | * @param float $l The base color lighting percentage (0 - 100) |
||
98 | * @param bool|null $is_dark Whether or not to treat the base color as a dark color. Leave as null to dynamically generate this. |
||
99 | * @return array An array of 5 triangular colors where the first offset is the original input. |
||
100 | */ |
||
101 | 1 | public static function tetrad_set (float $h = 0.0, float $s = 0.0, float $l = 0.0, $is_dark = NULL) :array { |
|
104 | |||
105 | /** |
||
106 | * 3 of these colors are all similarly distanced from each other on a color |
||
107 | * wheel, the base color has an alternate shade, and there is a weighted |
||
108 | * opposite color. These colors are all slightly closer to the base color |
||
109 | * than in a normal tetrad. |
||
110 | * |
||
111 | * @param float $h The base color hue degree (0 - 359) |
||
112 | * @param float $s The base color saturation percentage (0 - 100) |
||
113 | * @param float $l The base color lighting percentage (0 - 100) |
||
114 | * @param bool|null $is_dark Whether or not to treat the base color as a dark color. Leave as null to dynamically generate this. |
||
115 | * @return array An array of 5 triangular colors where the first offset is the original input. |
||
116 | */ |
||
117 | 1 | public static function weighted_tetrad_set (float $h = 0.0, float $s = 0.0, float $l = 0.0, $is_dark = NULL) :array { |
|
120 | |||
121 | /** |
||
122 | * These colors are all equally distanced from each other on a color wheel, |
||
123 | * 2 of which have an alternate shade. |
||
124 | * |
||
125 | * @param float $h The base color hue degree (0 - 359) |
||
126 | * @param float $s The base color saturation percentage (0 - 100) |
||
127 | * @param float $l The base color lighting percentage (0 - 100) |
||
128 | * @param bool|null $is_dark Whether or not to treat the base color as a dark color. Leave as null to dynamically generate this. |
||
129 | * @return array An array of 5 triangular colors where the first offset is the original input. |
||
130 | */ |
||
131 | 1 | public static function triad_set (float $h = 0.0, float $s = 0.0, float $l = 0.0, $is_dark = NULL) :array { |
|
134 | |||
135 | /** |
||
136 | * These colors are all similarly distanced from each other on a color wheel, |
||
137 | * 2 of which have an alternate shade. These colors are all slightly closer to |
||
138 | * the base color than in a normal triad. |
||
139 | * |
||
140 | * @param float $h The base color hue degree (0 - 359) |
||
141 | * @param float $s The base color saturation percentage (0 - 100) |
||
142 | * @param float $l The base color lighting percentage (0 - 100) |
||
143 | * @param bool|null $is_dark Whether or not to treat the base color as a dark color. Leave as null to dynamically generate this. |
||
144 | * @return array An array of 5 weighted triangular colors where the first offset is the original input. |
||
145 | */ |
||
146 | 1 | public static function weighted_triad_set (float $h = 0.0, float $s = 0.0, float $l = 0.0, $is_dark = NULL) :array { |
|
149 | |||
150 | /** |
||
151 | * 4 of these colors form a rectangle on a color wheel, and 1 color is an |
||
152 | * alternate shade for the base color. |
||
153 | * |
||
154 | * @param float $h The base color hue degree (0 - 359) |
||
155 | * @param float $s The base color saturation percentage (0 - 100) |
||
156 | * @param float $l The base color lighting percentage (0 - 100) |
||
157 | * @param bool|null $is_dark Whether or not to treat the base color as a dark color. Leave as null to dynamically generate this. |
||
158 | * @return array An array of 5 rectangular colors where the first offset is the original input. |
||
159 | */ |
||
160 | 1 | public static function rectangular_set (float $h = 0.0, float $s = 0.0, float $l = 0.0, $is_dark = NULL) :array { |
|
163 | |||
164 | /** |
||
165 | * Adjusts a hue in the YIQ spectrum |
||
166 | * |
||
167 | * @param float $current The current hue |
||
168 | * @param float $mod The desired amount of change (0 - 359; is converted to a percentage) |
||
169 | * @return int The resulting hue |
||
170 | */ |
||
171 | 15 | protected static function yiq_adjust(float $current, float $mod) :int { |
|
180 | |||
181 | /** |
||
182 | * Adjust a scheme array to use YIQ adjusted hues |
||
183 | * |
||
184 | * @param array $scheme The scheme to adjust |
||
185 | * @return array The resulting $scheme |
||
186 | */ |
||
187 | 15 | protected static function set_adjust(array $scheme) :array { |
|
198 | } |
||
199 |
If you define a variable conditionally, it can happen that it is not defined for all execution paths.
Let’s take a look at an example:
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.
Available Fixes
Check for existence of the variable explicitly:
Define a default value for the variable:
Add a value for the missing path: