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 |
||
28 | 60 | public static function compare($leftOperand, $rightOperand) |
|
29 | { |
||
30 | 60 | if (function_exists('bccomp')) { |
|
31 | 36 | return bccomp($leftOperand, $rightOperand, static::$scale); |
|
|
|||
32 | } |
||
33 | |||
34 | 24 | if ($leftOperand === $rightOperand) { |
|
35 | 6 | return 0; |
|
36 | } |
||
37 | |||
38 | 22 | return $leftOperand > $rightOperand ? 1 : -1; |
|
39 | } |
||
40 | |||
51 |
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: