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 |
||
31 | abstract class Display implements DisplayInterface, Arrayable |
||
32 | { |
||
33 | /** |
||
34 | * @var array |
||
35 | */ |
||
36 | protected $with = []; |
||
37 | |||
38 | /** |
||
39 | * @var \Illuminate\Database\Eloquent\Model |
||
40 | */ |
||
41 | protected $model; |
||
42 | |||
43 | /** |
||
44 | * @var null|RepositoryInterface |
||
45 | */ |
||
46 | protected $repository; |
||
47 | |||
48 | protected $type; |
||
49 | |||
50 | protected $extensions; |
||
51 | |||
52 | abstract public function get(); |
||
53 | |||
54 | public function __construct() |
||
62 | |||
63 | /** |
||
64 | * @param \Illuminate\Database\Eloquent\Model $model |
||
65 | * |
||
66 | * @return $this |
||
67 | */ |
||
68 | public function setModel(Model $model) |
||
74 | |||
75 | /** |
||
76 | * @return \Illuminate\Database\Eloquent\Model |
||
77 | */ |
||
78 | public function getModel() |
||
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | public function extend($name, ExtensionInterface $extension) |
||
92 | |||
93 | protected function makeRepository() |
||
101 | |||
102 | public function getRepository() |
||
110 | |||
111 | public function setRepository(RepositoryInterface $repository) |
||
117 | |||
118 | /** |
||
119 | * @return string[] |
||
120 | */ |
||
121 | public function getWith() |
||
125 | |||
126 | /** |
||
127 | * {@inheritdoc} |
||
128 | */ |
||
129 | public function with($relations) |
||
135 | |||
136 | /** |
||
137 | * {@inheritdoc} |
||
138 | */ |
||
139 | public function getQuery() |
||
153 | |||
154 | protected function apply(Builder $query) |
||
158 | |||
159 | /** |
||
160 | * Add an "order by" clause to the query. |
||
161 | * |
||
162 | * @param string $column |
||
163 | * @param string $direction |
||
164 | * |
||
165 | * @return $this |
||
166 | */ |
||
167 | public function orderBy($column, $direction = 'asc') |
||
175 | |||
176 | public function toArray() |
||
186 | |||
187 | public function __call($name, $parameters) |
||
216 | } |
||
217 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.