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 |
||
| 30 | abstract class Display implements DisplayInterface, Arrayable |
||
| 31 | { |
||
| 32 | /** |
||
| 33 | * @var array |
||
| 34 | */ |
||
| 35 | protected $with = []; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var \Illuminate\Database\Eloquent\Model |
||
| 39 | */ |
||
| 40 | protected $model; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @var RepositoryInterface |
||
| 44 | */ |
||
| 45 | protected $repository; |
||
| 46 | |||
| 47 | protected $type; |
||
| 48 | |||
| 49 | protected $extensions; |
||
| 50 | |||
| 51 | public function __construct() |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @param \Illuminate\Database\Eloquent\Model $model |
||
| 62 | * |
||
| 63 | * @return $this |
||
| 64 | */ |
||
| 65 | public function setModel(Model $model) |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @return \Illuminate\Database\Eloquent\Model |
||
| 74 | */ |
||
| 75 | public function getModel() |
||
| 79 | |||
| 80 | public function initialize() |
||
| 85 | |||
| 86 | public function extend($name, ExtensionInterface $extension) |
||
| 90 | |||
| 91 | protected function makeRepository() |
||
| 99 | |||
| 100 | public function getRepository() |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @return string[] |
||
| 107 | */ |
||
| 108 | public function getWith() |
||
| 112 | |||
| 113 | /** |
||
| 114 | * {@inheritdoc} |
||
| 115 | */ |
||
| 116 | public function with($relations) |
||
| 122 | |||
| 123 | public function getQuery() |
||
| 137 | |||
| 138 | protected function apply(Builder $query) |
||
| 142 | |||
| 143 | /** |
||
| 144 | * Add an "order by" clause to the query. |
||
| 145 | * |
||
| 146 | * @param string $column |
||
| 147 | * @param string $direction |
||
| 148 | * |
||
| 149 | * @return $this |
||
| 150 | */ |
||
| 151 | public function orderBy($column, $direction = 'asc') |
||
| 159 | |||
| 160 | public function toArray() |
||
| 170 | |||
| 171 | public function __call($name, $parameters) |
||
| 195 | } |
||
| 196 |
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.