Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php namespace Limoncello\Validation\Rules\Comparisons; |
||
26 | final class ScalarNotEquals extends BaseOneValueComparision |
||
27 | { |
||
28 | /** |
||
29 | * @param mixed $value |
||
30 | */ |
||
31 | public function __construct($value) |
||
36 | |||
37 | /** |
||
38 | * @inheritdoc |
||
39 | */ |
||
40 | View Code Duplication | public static function compare($value, ContextInterface $context): bool |
|
47 | |||
48 | /** |
||
49 | * @param mixed $value |
||
50 | * |
||
51 | * @return bool |
||
52 | */ |
||
53 | private static function isValidType($value): bool |
||
57 | } |
||
58 |
Late static binding only has effect in subclasses. A
final
class cannot be extended anymore so late static binding cannot occurr. Consider replacingstatic::
withself::
.To learn more about late static binding, please refer to the PHP core documentation.