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 |
||
| 8 | trait BelongsToRelation |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var string |
||
| 12 | */ |
||
| 13 | protected $modalID; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | protected $selectable; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * BelongsToRelation constructor. |
||
| 22 | * @param string $column |
||
| 23 | * @param array $arguments |
||
| 24 | */ |
||
| 25 | public function __construct($column, $arguments = []) |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @param string $selectable |
||
| 34 | */ |
||
| 35 | protected function setSelectable($selectable) |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return string |
||
| 48 | */ |
||
| 49 | public function getSelectable() |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @param int $multiple |
||
| 56 | * @return string |
||
| 57 | */ |
||
| 58 | protected function getLoadUrl($multiple = 0) |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @return $this |
||
| 67 | */ |
||
| 68 | View Code Duplication | public function addHtml() |
|
| 101 | |||
| 102 | /** |
||
| 103 | * @return $this |
||
| 104 | */ |
||
| 105 | public function addStyle() |
||
| 134 | |||
| 135 | /** |
||
| 136 | * @return \Encore\Admin\Grid |
||
| 137 | */ |
||
| 138 | protected function makeGrid() |
||
| 145 | |||
| 146 | /** |
||
| 147 | * {@inheritdoc} |
||
| 148 | */ |
||
| 149 | public function render() |
||
| 162 | } |
||
| 163 |