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 null|RepositoryInterface |
||
| 44 | */ |
||
| 45 | protected $repository; |
||
| 46 | |||
| 47 | protected $type; |
||
| 48 | |||
| 49 | protected $extensions; |
||
| 50 | |||
| 51 | abstract public function get(); |
||
| 52 | |||
| 53 | public function __construct() |
||
| 61 | |||
| 62 | /** |
||
| 63 | * {@inheritdoc} |
||
| 64 | */ |
||
| 65 | public function setModel(Model $model) |
||
| 71 | |||
| 72 | /** |
||
| 73 | * {@inheritdoc} |
||
| 74 | */ |
||
| 75 | public function getModel() |
||
| 79 | |||
| 80 | /** |
||
| 81 | * {@inheritdoc} |
||
| 82 | */ |
||
| 83 | public function extend($name, ExtensionInterface $extension) |
||
| 89 | |||
| 90 | protected function makeRepository() |
||
| 98 | |||
| 99 | /** |
||
| 100 | * {@inheritdoc} |
||
| 101 | */ |
||
| 102 | public function getRepository() |
||
| 110 | |||
| 111 | /** |
||
| 112 | * {@inheritdoc} |
||
| 113 | */ |
||
| 114 | public function setRepository(RepositoryInterface $repository) |
||
| 120 | |||
| 121 | /** |
||
| 122 | * {@inheritdoc} |
||
| 123 | */ |
||
| 124 | public function getWith() |
||
| 128 | |||
| 129 | /** |
||
| 130 | * {@inheritdoc} |
||
| 131 | */ |
||
| 132 | public function with($relations) |
||
| 138 | |||
| 139 | /** |
||
| 140 | * {@inheritdoc} |
||
| 141 | */ |
||
| 142 | public function getQuery() |
||
| 156 | |||
| 157 | protected function apply(Builder $query) |
||
| 161 | |||
| 162 | /** |
||
| 163 | * {@inheritdoc} |
||
| 164 | */ |
||
| 165 | public function orderBy($column, $direction = 'asc') |
||
| 173 | |||
| 174 | public function toArray() |
||
| 184 | |||
| 185 | public function __call($name, $parameters) |
||
| 209 | } |
||
| 210 |
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.