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 |
||
20 | final class OperatorToken extends AbstractToken |
||
21 | { |
||
22 | /** |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected static $operators = array('*', '/', '+', '-', '^'); |
||
27 | |||
28 | /** |
||
29 | * |
||
30 | * @param string $assoc |
||
31 | * @return integer |
||
32 | */ |
||
33 | 21 | public function getPriority($assoc = 'left') |
|
61 | |||
62 | /** |
||
63 | * |
||
64 | * @return boolean |
||
65 | */ |
||
66 | 21 | public function isLeftAssoc() |
|
70 | |||
71 | /** |
||
72 | * |
||
73 | * @return boolean |
||
74 | */ |
||
75 | 21 | public function isRightAssoc() |
|
79 | |||
80 | /** |
||
81 | * |
||
82 | * @return array |
||
83 | */ |
||
84 | 44 | public static function getAllowedOperators() |
|
88 | |||
89 | /** |
||
90 | * |
||
91 | * @param string $value |
||
92 | * @return string |
||
93 | */ |
||
94 | 37 | protected function sanitize($value) |
|
98 | |||
99 | /** |
||
100 | * |
||
101 | * @param string $value |
||
102 | * @return boolean |
||
103 | */ |
||
104 | 44 | public static function validate($value) |
|
108 | } |
||
109 |