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 |
||
9 | class Last { |
||
10 | private $baseData; |
||
|
|||
11 | private $autoLookup; |
||
12 | /* |
||
13 | Stores the last value e.g. |
||
14 | "a" + "b" |
||
15 | Will store "a" before reading the token for the + and perfoming the concatenate operation |
||
16 | */ |
||
17 | private $last; |
||
18 | private $data; |
||
19 | private $result; |
||
20 | private $traversing = false; |
||
21 | |||
22 | |||
23 | public function __construct($data, $result, $autoLookup) { |
||
28 | |||
29 | |||
30 | public function traverse() { |
||
40 | |||
41 | public function clear() { |
||
44 | |||
45 | public function isEmpty() { |
||
48 | |||
49 | public function processNested($parser, $token) { |
||
54 | |||
55 | public function read() { |
||
58 | |||
59 | public function set($value) { |
||
62 | |||
63 | |||
64 | //Applies the current operation to whatever is in $last based on $mode |
||
65 | View Code Duplication | public function process() { |
|
76 | |||
77 | View Code Duplication | private function processLastUnexpected() { |
|
86 | } |
This check marks private properties in classes that are never used. Those properties can be removed.