Conditions | 1 |
Paths | 1 |
Total Lines | 66 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
56 | public function getVariantArrayData(): array |
||
57 | { |
||
58 | return [ |
||
59 | 'single variant' => [ |
||
60 | [ |
||
61 | [ |
||
62 | "uuid" => (string) Uuid::uuid1(), |
||
63 | "name" => "a variant name", |
||
64 | "description" => 'the variant description', |
||
65 | "sku" => null, |
||
66 | "barcode" => null, |
||
67 | "defaultQuantity" => "1", |
||
68 | "unitName" => null, |
||
69 | "price" => [ |
||
70 | "amount" => 1000, |
||
71 | "currencyId" => "EUR", |
||
72 | ], |
||
73 | "costPrice" => null, |
||
74 | "vatPercentage" => "6.0", |
||
75 | ], |
||
76 | ], |
||
77 | ], |
||
78 | 'multiple variant' =>[ |
||
79 | [ |
||
80 | [ |
||
81 | "uuid" => (string) Uuid::uuid1(), |
||
82 | "name" => "Variant A", |
||
83 | "description" => null, |
||
84 | "sku" => 'Prod-VarA', |
||
85 | "barcode" => '9782123456803', |
||
86 | "defaultQuantity" => "1", |
||
87 | "unitName" => null, |
||
88 | "price" => [ |
||
89 | "amount" => 1200, |
||
90 | "currencyId" => "EUR", |
||
91 | ], |
||
92 | "costPrice" => [ |
||
93 | "amount" => 700, |
||
94 | "currencyId" => "EUR", |
||
95 | ], |
||
96 | "vatPercentage" => "6.0", |
||
97 | ], |
||
98 | ], |
||
99 | [ |
||
100 | [ |
||
101 | "uuid" => (string) Uuid::uuid1(), |
||
102 | "name" => "Variant B", |
||
103 | "description" => null, |
||
104 | "sku" => 'Prod-VarB', |
||
105 | "barcode" => null, |
||
106 | "defaultQuantity" => "1", |
||
107 | "unitName" => null, |
||
108 | "price" => [ |
||
109 | "amount" => 1500, |
||
110 | "currencyId" => "EUR", |
||
111 | ], |
||
112 | "costPrice" => [ |
||
113 | "amount" => 900, |
||
114 | "currencyId" => "EUR", |
||
115 | ], |
||
116 | "vatPercentage" => "6.0", |
||
117 | ], |
||
118 | ], |
||
119 | ], |
||
120 | ]; |
||
121 | } |
||
122 | } |
||
123 |