Conditions | 1 |
Paths | 1 |
Total Lines | 103 |
Code Lines | 76 |
Lines | 0 |
Ratio | 0 % |
Changes | 5 | ||
Bugs | 0 | Features | 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 |
||
123 | public function configure(DataTable $dataTable, array $options) |
||
124 | { |
||
125 | $dataTable |
||
126 | ->add('name', TextColumn::class, [ |
||
127 | 'label' => $this->translator->trans('part.table.name'), |
||
128 | 'render' => function ($value, Part $context) { |
||
129 | return $this->urlGenerator->infoHTML($context); |
||
130 | }, |
||
131 | ]) |
||
132 | ->add('id', TextColumn::class, [ |
||
133 | 'label' => $this->translator->trans('part.table.id'), |
||
134 | 'visible' => false |
||
135 | ]) |
||
136 | ->add('description', TextColumn::class, [ |
||
137 | 'label' => $this->translator->trans('part.table.description'), |
||
138 | ]) |
||
139 | ->add('category', EntityColumn::class, [ |
||
140 | 'label' => $this->translator->trans('part.table.category'), |
||
141 | 'property' => 'category' |
||
142 | ]) |
||
143 | ->add('footprint', EntityColumn::class, [ |
||
144 | 'property' => 'footprint', |
||
145 | 'label' => $this->translator->trans('part.table.footprint') |
||
146 | ]) |
||
147 | ->add('manufacturer', EntityColumn::class, [ |
||
148 | 'property' => 'manufacturer', |
||
149 | 'label' => $this->translator->trans('part.table.manufacturer') |
||
150 | ]) |
||
151 | //->add('footprint', TextColumn::class, ['field' => 'footprint.name']) |
||
152 | //->add('manufacturer', TextColumn::class, ['field' => 'manufacturer.name' ]) |
||
153 | //->add('amountSum', TextColumn::class, ['label' => 'instock.label_short']) |
||
154 | ->add('amount', TextColumn::class, [ |
||
155 | 'label' => $this->translator->trans('part.table.amount'), |
||
156 | 'propertyPath' => 'amountSum' |
||
157 | ]) |
||
158 | ->add('minamount', TextColumn::class, [ |
||
159 | 'label' => $this->translator->trans('part.table.minamount'), |
||
160 | 'visible' => false |
||
161 | ]) |
||
162 | ->add('partUnit', TextColumn::class, [ |
||
163 | 'field' => 'partUnit.name', |
||
164 | 'label' => $this->translator->trans('part.table.partUnit'), |
||
165 | 'visible' => false |
||
166 | ]) |
||
167 | ->add('addedDate', LocaleDateTimeColumn::class, [ |
||
168 | 'label' => $this->translator->trans('part.table.addedDate'), |
||
169 | 'visible' => false |
||
170 | ]) |
||
171 | ->add('lastModified', LocaleDateTimeColumn::class, [ |
||
172 | 'label' => $this->translator->trans('part.table.lastModified'), |
||
173 | 'visible' => false |
||
174 | ]) |
||
175 | ->add('needs_review', BoolColumn::class, [ |
||
176 | 'label' => $this->translator->trans('part.table.needsReview'), |
||
177 | 'trueValue' => $this->translator->trans('true'), |
||
178 | 'falseValue' => $this->translator->trans('false'), |
||
179 | 'nullValue' => '', |
||
180 | 'visible' => false |
||
181 | ]) |
||
182 | ->add('favorite', BoolColumn::class, [ |
||
183 | 'label' => $this->translator->trans('part.table.favorite'), |
||
184 | 'trueValue' => $this->translator->trans('true'), |
||
185 | 'falseValue' => $this->translator->trans('false'), |
||
186 | 'nullValue' => '', |
||
187 | 'visible' => false |
||
188 | ]) |
||
189 | ->add('manufacturing_status', MapColumn::class, [ |
||
190 | 'label' => $this->translator->trans('part.table.manufacturingStatus'), |
||
191 | 'visible' => false, |
||
192 | 'default' => $this->translator->trans('m_status.unknown'), |
||
193 | 'map' => [ |
||
194 | '' => $this->translator->trans('m_status.unknown'), |
||
195 | 'announced' => $this->translator->trans('m_status.announced'), |
||
196 | 'active' => $this->translator->trans('m_status.active'), |
||
197 | 'nrfnd' => $this->translator->trans('m_status.nrfnd'), |
||
198 | 'eol' => $this->translator->trans('m_status.eol'), |
||
199 | 'discontinued' => $this->translator->trans('m_status.discontinued') |
||
200 | ] |
||
201 | ]) |
||
202 | ->add('manufacturer_product_number', TextColumn::class, [ |
||
203 | 'label' => $this->translator->trans('part.table.mpn'), |
||
204 | 'visible' => false |
||
205 | ]) |
||
206 | ->add('mass', TextColumn::class, [ |
||
207 | 'label' => $this->translator->trans('part.table.mass'), |
||
208 | 'visible' => false |
||
209 | ]) |
||
210 | ->add('tags', TextColumn::class, [ |
||
211 | 'label' => $this->translator->trans('part.table.tags'), |
||
212 | 'visible' => false |
||
213 | ]) |
||
214 | |||
215 | ->addOrderBy('name') |
||
216 | ->createAdapter(ORMAdapter::class, [ |
||
217 | 'query' => function(QueryBuilder $builder) { |
||
218 | $this->getQuery($builder); |
||
219 | }, |
||
220 | 'entity' => Part::class, |
||
221 | 'criteria' => [ |
||
222 | function (QueryBuilder $builder) use ($options) { |
||
223 | $this->buildCriteria($builder, $options); |
||
224 | }, |
||
225 | new SearchCriteriaProvider() |
||
226 | ] |
||
230 |