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 namespace VojtaSvoboda\Reservations\Controllers; |
||
| 11 | class Reservations extends Controller |
||
| 12 | { |
||
| 13 | public $implement = [ |
||
| 14 | 'Backend\Behaviors\ListController', |
||
| 15 | 'Backend\Behaviors\FormController', |
||
| 16 | 'Backend\Behaviors\ImportExportController', |
||
| 17 | ]; |
||
| 18 | |||
| 19 | public $listConfig = 'config_list.yaml'; |
||
| 20 | public $formConfig = 'config_form.yaml'; |
||
| 21 | public $importExportConfig = 'config_import_export.yaml'; |
||
| 22 | |||
| 23 | private $stateColors; |
||
| 24 | private $stateNames; |
||
| 25 | |||
| 26 | public $requiredPermissions = [ |
||
| 27 | 'vojtasvoboda.reservations.reservations', |
||
| 28 | ]; |
||
| 29 | |||
| 30 | public function __construct() |
||
| 37 | |||
| 38 | public function index() |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Override displaying reservation status. |
||
| 47 | * |
||
| 48 | * @param $record |
||
| 49 | * @param $columnName |
||
| 50 | * @param null $definition |
||
| 51 | * |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | public function listOverrideColumnValue($record, $columnName, $definition = null) |
||
| 68 | |||
| 69 | /** |
||
| 70 | * Bulk actions |
||
| 71 | * |
||
| 72 | * @return mixed |
||
| 73 | */ |
||
| 74 | public function index_onBulkAction() |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Return if User is returning. |
||
| 96 | * |
||
| 97 | * @param string $email Users email |
||
| 98 | * |
||
| 99 | * @return bool |
||
| 100 | */ |
||
| 101 | private function isReturning($email) |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Get color by state ident. |
||
| 111 | * |
||
| 112 | * @param $ident |
||
| 113 | * |
||
| 114 | * @return null |
||
| 115 | */ |
||
| 116 | View Code Duplication | private function getStateColor($ident) |
|
| 124 | |||
| 125 | /** |
||
| 126 | * Get name by state ident. |
||
| 127 | * |
||
| 128 | * @param $ident |
||
| 129 | * |
||
| 130 | * @return null |
||
| 131 | */ |
||
| 132 | View Code Duplication | private function getStateName($ident) |
|
| 140 | } |
||
| 141 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.