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 |
||
21 | class ValidatorChain extends Base implements ChainInterface |
||
|
|||
22 | { |
||
23 | |||
24 | /** |
||
25 | * @readwrite |
||
26 | * @var ValidatorInterface[] |
||
27 | */ |
||
28 | protected $_validators = []; |
||
29 | |||
30 | /** |
||
31 | * @readwrite |
||
32 | * @var array |
||
33 | */ |
||
34 | protected $_messages = []; |
||
35 | |||
36 | /** |
||
37 | * Returns true if and only if $value meets the validation requirements |
||
38 | * |
||
39 | * @param mixed $value |
||
40 | * @return bool |
||
41 | */ |
||
42 | public function isValid($value) |
||
55 | |||
56 | /** |
||
57 | * Returns an array of messages that explain why the most recent |
||
58 | * isValid() call returned false. The array keys are validation failure |
||
59 | * message identifiers, and the array values are the corresponding |
||
60 | * human-readable message strings. |
||
61 | * |
||
62 | * @return array |
||
63 | */ |
||
64 | public function getMessages() |
||
68 | |||
69 | /** |
||
70 | * Adds a validator to the chain |
||
71 | * |
||
72 | * @param ValidatorInterface $validator |
||
73 | * |
||
74 | * @return ValidatorChain |
||
75 | */ |
||
76 | public function add(ValidatorInterface $validator) |
||
81 | } |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.