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 |
||
5 | abstract class MarketModel |
||
6 | { |
||
7 | |||
8 | protected $mappingClasses = []; |
||
9 | |||
10 | /** |
||
11 | * Constructor |
||
12 | * |
||
13 | * @param array $data |
||
14 | */ |
||
15 | public function __construct($data = []) |
||
19 | |||
20 | /** |
||
21 | * Set from array |
||
22 | * |
||
23 | * @param array $data |
||
24 | * @return $this |
||
25 | */ |
||
26 | public function fromArray($data) |
||
48 | |||
49 | /** |
||
50 | * Set from json |
||
51 | * |
||
52 | * @param string $json |
||
53 | * @return $this |
||
54 | */ |
||
55 | public function fromJson($json) |
||
60 | |||
61 | /** |
||
62 | * Get array from object |
||
63 | * |
||
64 | * @return array |
||
65 | */ |
||
66 | public function toArray() |
||
70 | |||
71 | /** |
||
72 | * Get array from object |
||
73 | * |
||
74 | * @return string |
||
75 | */ |
||
76 | public function toJson() |
||
80 | |||
81 | /** |
||
82 | * Get array from object |
||
83 | * |
||
84 | * @param array|object $data |
||
85 | * @return array |
||
86 | */ |
||
87 | protected function toArrayRecursive($data) |
||
107 | } |
||
108 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.