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 |
||
| 9 | class LotRepository extends Repository |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @return Lot |
||
| 13 | */ |
||
| 14 | public function getModel() |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Create plain lot for attached items to him. |
||
| 21 | * |
||
| 22 | * @param Vendor $vendor |
||
| 23 | * @return mixed |
||
| 24 | */ |
||
| 25 | public function createDraft(Vendor $vendor) |
||
| 32 | |||
| 33 | View Code Duplication | public function find($slug) |
|
| 44 | |||
| 45 | public function statusChange(){ |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Add empty lot or modify just existed (drafted).. |
||
| 51 | * |
||
| 52 | * @param $vendor |
||
| 53 | * @return Lot|mixed |
||
| 54 | */ |
||
| 55 | public function addLot($vendor) |
||
| 62 | |||
| 63 | /** |
||
| 64 | * Get drafted lot |
||
| 65 | * |
||
| 66 | * @param $vendor|null |
||
| 67 | * @return Lot $Lot|null |
||
| 68 | */ |
||
| 69 | public function getDraftedLot($vendor = null) |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Get user's lots. |
||
| 83 | * |
||
| 84 | * @param $user |
||
| 85 | * @param $perPage |
||
| 86 | * @return \Illuminate\Support\Collection|null |
||
| 87 | */ |
||
| 88 | public function userLots($user, $perPage = 5) |
||
| 108 | |||
| 109 | public function userLotsPendingComision($user,$lotId=null) |
||
| 129 | |||
| 130 | /** |
||
| 131 | * Delete lot. |
||
| 132 | * |
||
| 133 | * @param $lot |
||
| 134 | */ |
||
| 135 | public function delete($lot) |
||
| 145 | |||
| 146 | /** |
||
| 147 | * Convert string date to \Carbon/Carbon timestamp. |
||
| 148 | * |
||
| 149 | * @param $date |
||
| 150 | * @return static |
||
| 151 | */ |
||
| 152 | public function dateToTimestamp($date) |
||
| 158 | |||
| 159 | /** |
||
| 160 | * Reformat date. |
||
| 161 | * |
||
| 162 | * @param $date |
||
| 163 | * @param string $delimiter |
||
| 164 | * @return mixed |
||
| 165 | */ |
||
| 166 | public function reformatDateString($date, $delimiter = '.') |
||
| 183 | |||
| 184 | public function save($lot, array $data) |
||
| 200 | |||
| 201 | |||
| 202 | /** |
||
| 203 | * Change category. |
||
| 204 | * |
||
| 205 | * @param $lot |
||
| 206 | * @param $category_id |
||
| 207 | * |
||
| 208 | * @return void |
||
| 209 | */ |
||
| 210 | public function changeCategory($lot, $category_id) |
||
| 216 | |||
| 217 | /** |
||
| 218 | * Check if user can to change category. |
||
| 219 | * |
||
| 220 | * @param Lot $lot |
||
| 221 | * @return bool |
||
| 222 | */ |
||
| 223 | public function checkIfPossibleToChangeCategory(Lot $lot) |
||
| 230 | |||
| 231 | public function getLatestLot($limit = 10) |
||
| 239 | |||
| 240 | public function getExpireSoon($paginate = 10) |
||
| 250 | |||
| 251 | } |
Since your code implements the magic getter
_get, this function will be called for any read access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.