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 |
||
| 11 | class DropdownActions extends Actions |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var array |
||
| 15 | */ |
||
| 16 | protected $custom = []; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var array |
||
| 20 | */ |
||
| 21 | protected $default = []; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * @var array |
||
| 25 | */ |
||
| 26 | protected $defaultClass = [Edit::class, Show::class, Delete::class]; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Add JS script into pages. |
||
| 30 | * |
||
| 31 | * @return void. |
||
|
|
|||
| 32 | */ |
||
| 33 | protected function addScript() |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param RowAction $action |
||
| 52 | * |
||
| 53 | * @return $this |
||
| 54 | */ |
||
| 55 | public function add(RowAction $action) |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Prepend default `edit` `view` `delete` actions. |
||
| 66 | */ |
||
| 67 | protected function prependDefaultActions() |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @param RowAction $action |
||
| 81 | */ |
||
| 82 | protected function prepareAction(RowAction $action) |
||
| 88 | |||
| 89 | /** |
||
| 90 | * Disable view action. |
||
| 91 | * |
||
| 92 | * @param bool $disable |
||
| 93 | * |
||
| 94 | * @return $this |
||
| 95 | */ |
||
| 96 | View Code Duplication | public function disableView(bool $disable = true) |
|
| 106 | |||
| 107 | /** |
||
| 108 | * Disable delete. |
||
| 109 | * |
||
| 110 | * @param bool $disable |
||
| 111 | * |
||
| 112 | * @return $this. |
||
| 113 | */ |
||
| 114 | View Code Duplication | public function disableDelete(bool $disable = true) |
|
| 124 | |||
| 125 | /** |
||
| 126 | * Disable edit. |
||
| 127 | * |
||
| 128 | * @param bool $disable |
||
| 129 | * |
||
| 130 | * @return $this |
||
| 131 | */ |
||
| 132 | View Code Duplication | public function disableEdit(bool $disable = true) |
|
| 142 | |||
| 143 | /** |
||
| 144 | * @param null|\Closure $callback |
||
| 145 | * |
||
| 146 | * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
||
| 147 | */ |
||
| 148 | public function display($callback = null) |
||
| 165 | } |
||
| 166 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.