Conditions | 4 |
Paths | 4 |
Total Lines | 12 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Tests | 6 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | 60 | public static function compare($leftOperand, $rightOperand) |
|
28 | { |
||
29 | 60 | if (function_exists('bccomp')) { |
|
30 | 36 | return bccomp($leftOperand, $rightOperand, static::$scale); |
|
|
|||
31 | } |
||
32 | |||
33 | 24 | if ($leftOperand === $rightOperand) { |
|
34 | 6 | return 0; |
|
35 | } |
||
36 | |||
37 | 22 | return $leftOperand > $rightOperand ? 1 : -1; |
|
38 | } |
||
39 | |||
50 |
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: