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 | trait Taxable |
||
10 | { |
||
11 | /** |
||
12 | * Column name used for get the price of the model. |
||
13 | * |
||
14 | * @return string Column name |
||
15 | */ |
||
16 | public static function priceColumn() |
||
20 | |||
21 | /** |
||
22 | * [taxGroups description]. |
||
23 | * |
||
24 | * @return [type] [description] |
||
|
|||
25 | */ |
||
26 | public function taxGroups(): MorphToMany |
||
36 | |||
37 | public function hasTaxGroups() |
||
41 | |||
42 | /** |
||
43 | * Determine if the model has (one of) the given tax group(s). |
||
44 | * |
||
45 | * @param string|array|\FeiMx\Tax\Models\TaxGroup|\Illuminate\Support\Collection $taxGroups |
||
46 | * |
||
47 | * @return bool |
||
48 | */ |
||
49 | public function hasTaxGroup($taxGroups) |
||
69 | |||
70 | /** |
||
71 | * Assign the given taxGroup to the model. |
||
72 | * |
||
73 | * @param array|string|\FeiMx\Tax\Models\TaxGroup ...$taxGroups |
||
74 | * |
||
75 | * @return $this |
||
76 | */ |
||
77 | public function assignTaxGroup(...$taxGroups) |
||
94 | |||
95 | /** |
||
96 | * Revoke the given role from the model. |
||
97 | * |
||
98 | * @param string|\FeiMx\Tax\Models\TaxGroup $taxGroup |
||
99 | */ |
||
100 | public function removeTaxGroup($taxGroup) |
||
104 | |||
105 | /** |
||
106 | * Remove all current tax groups and set the given ones. |
||
107 | * |
||
108 | * @param array|\FeiMx\Tax\Models\TaxGroup|string ...$taxGroups |
||
109 | * |
||
110 | * @return $this |
||
111 | */ |
||
112 | public function syncTaxGroups(...$taxGroups) |
||
118 | |||
119 | /** |
||
120 | * Get total amount for current TaxGroup. |
||
121 | * |
||
122 | * @param \FeiMx\Tax\Models\TaxGroup|string $taxGroup |
||
123 | * |
||
124 | * @return $total |
||
125 | */ |
||
126 | View Code Duplication | public function total($taxGroup = null) |
|
144 | |||
145 | /** |
||
146 | * Get a list of taxes with amount calculated for the given TaxGroup. |
||
147 | * |
||
148 | * @param \FeiMx\Tax\Models\TaxGroup|string $taxGroup |
||
149 | * |
||
150 | * @return $total |
||
151 | */ |
||
152 | View Code Duplication | public function getAmounts($taxGroup = null) |
|
170 | |||
171 | protected function getStoredTaxGroup($taxGroup): TaxGroup |
||
182 | } |
||
183 |
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.