Conditions | 6 |
Paths | 5 |
Total Lines | 17 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
308 | public static function validateColour(Terminal $terminal, $colour, string $fallback = null) |
||
309 | { |
||
310 | if (is_int($colour)) { |
||
311 | if ($colour < 0 || $colour > 255) { |
||
312 | throw new \InvalidArgumentException("Invalid colour code"); |
||
313 | } |
||
314 | if ($terminal->getColourSupport() < 256) { |
||
315 | if ($fallback !== null) { |
||
316 | Assertion::inArray($fallback, static::getDefaultColoursNames()); |
||
317 | return $fallback; |
||
318 | } |
||
319 | return static::map256To8($colour); |
||
320 | } |
||
321 | } |
||
322 | Assertion::inArray($colour, static::getDefaultColoursNames()); |
||
323 | return $colour; |
||
324 | } |
||
325 | } |
||
326 |
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: