Conditions | 1 |
Paths | 1 |
Total Lines | 145 |
Code Lines | 99 |
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 |
||
55 | public function configureColumns(ColumnCollection $collection) |
||
56 | { |
||
57 | $collection->add(new Column([ |
||
58 | 'id' => 'id', |
||
59 | 'caption' => 'order.label.id', |
||
60 | 'appearance' => new Appearance([ |
||
61 | 'width' => 40, |
||
62 | 'visible' => false, |
||
63 | 'align' => Appearance::ALIGN_CENTER, |
||
64 | ]), |
||
65 | 'filter' => new Filter([ |
||
66 | 'type' => Filter::FILTER_BETWEEN, |
||
67 | ]), |
||
68 | ])); |
||
69 | |||
70 | $collection->add(new Column([ |
||
71 | 'id' => 'number', |
||
72 | 'caption' => 'order.label.number', |
||
73 | 'filter' => new Filter([ |
||
74 | 'type' => Filter::FILTER_INPUT, |
||
75 | ]), |
||
76 | 'sorting' => new Sorting([ |
||
77 | 'default_order' => Sorting::SORT_DIR_DESC, |
||
78 | ]), |
||
79 | 'appearance' => new Appearance([ |
||
80 | 'width' => 40, |
||
81 | 'align' => Appearance::ALIGN_CENTER, |
||
82 | ]), |
||
83 | ])); |
||
84 | |||
85 | $collection->add(new Column([ |
||
86 | 'id' => 'client', |
||
87 | 'caption' => 'order.label.client', |
||
88 | 'filter' => new Filter([ |
||
89 | 'type' => Filter::FILTER_INPUT, |
||
90 | ]), |
||
91 | 'appearance' => new Appearance([ |
||
92 | 'width' => 140, |
||
93 | 'align' => Appearance::ALIGN_LEFT, |
||
94 | ]), |
||
95 | ])); |
||
96 | |||
97 | $collection->add(new Column([ |
||
98 | 'id' => 'products', |
||
99 | 'caption' => 'order.label.products', |
||
100 | 'filter' => new Filter([ |
||
101 | 'type' => Filter::FILTER_INPUT, |
||
102 | ]), |
||
103 | 'appearance' => new Appearance([ |
||
104 | 'width' => 140, |
||
105 | 'align' => Appearance::ALIGN_LEFT, |
||
106 | ]), |
||
107 | ])); |
||
108 | |||
109 | $collection->add(new Column([ |
||
110 | 'id' => 'productTotal', |
||
111 | 'caption' => 'order.label.product_total.gross_price', |
||
112 | 'filter' => new Filter([ |
||
113 | 'type' => Filter::FILTER_BETWEEN, |
||
114 | ]), |
||
115 | 'appearance' => new Appearance([ |
||
116 | 'width' => 40, |
||
117 | 'align' => Appearance::ALIGN_CENTER, |
||
118 | ]), |
||
119 | ])); |
||
120 | |||
121 | $collection->add(new Column([ |
||
122 | 'id' => 'orderTotal', |
||
123 | 'caption' => 'order.label.order_total', |
||
124 | 'filter' => new Filter([ |
||
125 | 'type' => Filter::FILTER_BETWEEN, |
||
126 | ]), |
||
127 | 'appearance' => new Appearance([ |
||
128 | 'width' => 40, |
||
129 | 'align' => Appearance::ALIGN_CENTER, |
||
130 | ]), |
||
131 | ])); |
||
132 | |||
133 | $collection->add(new Column([ |
||
134 | 'id' => 'currency', |
||
135 | 'caption' => 'order.label.currency', |
||
136 | 'filter' => new Filter([ |
||
137 | 'type' => Filter::FILTER_BETWEEN, |
||
138 | ]), |
||
139 | 'appearance' => new Appearance([ |
||
140 | 'width' => 40, |
||
141 | 'visible' => false, |
||
142 | 'align' => Appearance::ALIGN_CENTER, |
||
143 | ]), |
||
144 | ])); |
||
145 | |||
146 | $collection->add(new Column([ |
||
147 | 'id' => 'currentStatusName', |
||
148 | 'caption' => 'order.label.current_status', |
||
149 | 'filter' => new Filter([ |
||
150 | 'type' => Filter::FILTER_TREE, |
||
151 | 'filtered_column' => 'currentStatusId', |
||
152 | 'options' => $this->statuses->getOptions(), |
||
153 | ]), |
||
154 | 'appearance' => new Appearance([ |
||
155 | 'width' => 60, |
||
156 | 'align' => Appearance::ALIGN_CENTER, |
||
157 | ]), |
||
158 | ])); |
||
159 | |||
160 | $collection->add(new Column([ |
||
161 | 'id' => 'paymentMethodName', |
||
162 | 'caption' => 'order.label.payment_method', |
||
163 | 'filter' => new Filter([ |
||
164 | 'type' => Filter::FILTER_TREE, |
||
165 | 'filtered_column' => 'paymentMethodId', |
||
166 | 'options' => $this->paymentMethods->getOptions(), |
||
167 | ]), |
||
168 | 'appearance' => new Appearance([ |
||
169 | 'width' => 60, |
||
170 | 'align' => Appearance::ALIGN_CENTER, |
||
171 | ]), |
||
172 | ])); |
||
173 | |||
174 | $collection->add(new Column([ |
||
175 | 'id' => 'shippingMethodName', |
||
176 | 'caption' => 'order.label.shipping_method', |
||
177 | 'filter' => new Filter([ |
||
178 | 'type' => Filter::FILTER_TREE, |
||
179 | 'filtered_column' => 'shippingMethodId', |
||
180 | 'options' => $this->shippingMethods->getOptions(), |
||
181 | ]), |
||
182 | 'appearance' => new Appearance([ |
||
183 | 'width' => 60, |
||
184 | 'align' => Appearance::ALIGN_CENTER, |
||
185 | ]), |
||
186 | ])); |
||
187 | |||
188 | $collection->add(new Column([ |
||
189 | 'id' => 'createdAt', |
||
190 | 'caption' => 'order.label.created_at', |
||
191 | 'filter' => new Filter([ |
||
192 | 'type' => Filter::FILTER_BETWEEN, |
||
193 | ]), |
||
194 | 'appearance' => new Appearance([ |
||
195 | 'width' => 40, |
||
196 | 'align' => Appearance::ALIGN_CENTER, |
||
197 | ]), |
||
198 | ])); |
||
199 | } |
||
200 | |||
233 |