Conditions | 1 |
Paths | 1 |
Total Lines | 88 |
Code Lines | 63 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
86 | public function configure(DataTable $dataTable, array $options) |
||
87 | { |
||
88 | $dataTable |
||
89 | ->add('name', TextColumn::class, [ |
||
90 | 'label' => $this->translator->trans('part.table.name'), |
||
91 | 'render' => function ($value, Part $context) { |
||
92 | return $this->urlGenerator->infoHTML($context); |
||
93 | }, |
||
94 | ]) |
||
95 | ->add('id', TextColumn::class, [ |
||
96 | 'label' => $this->translator->trans('part.table.id'), |
||
97 | 'visible' => false |
||
98 | ]) |
||
99 | ->add('description', TextColumn::class, [ |
||
100 | 'label' => $this->translator->trans('part.table.description'), |
||
101 | ]) |
||
102 | ->add('category', TextColumn::class, [ |
||
103 | 'field' => 'category.name', |
||
104 | 'label' => $this->translator->trans('part.table.category') |
||
105 | ]) |
||
106 | //->add('footprint', TextColumn::class, ['field' => 'footprint.name']) |
||
107 | //->add('manufacturer', TextColumn::class, ['field' => 'manufacturer.name' ]) |
||
108 | //->add('amountSum', TextColumn::class, ['label' => 'instock.label_short']) |
||
109 | ->add('amount', TextColumn::class, [ |
||
110 | 'label' => $this->translator->trans('part.table.amount'), |
||
111 | 'propertyPath' => 'amountSum' |
||
112 | ]) |
||
113 | ->add('minamount', TextColumn::class, [ |
||
114 | 'label' => $this->translator->trans('part.table.minamount') |
||
115 | ]) |
||
116 | //->add('storelocation', TextColumn::class, ['field' => 'storelocation.name', 'label' => 'storelocation.label']) |
||
117 | |||
118 | ->add('addedDate', DateTimeColumn::class, [ |
||
119 | 'label' => $this->translator->trans('part.table.addedDate'), |
||
120 | 'visible' => false |
||
121 | ]) |
||
122 | ->add('lastModified', DateTimeColumn::class, [ |
||
123 | 'label' => $this->translator->trans('part.table.lastModified'), |
||
124 | 'visible' => false |
||
125 | ]) |
||
126 | ->add('needs_review', BoolColumn::class, [ |
||
127 | 'label' => $this->translator->trans('part.table.needsReview'), |
||
128 | 'trueValue' => $this->translator->trans('true'), |
||
129 | 'falseValue' => $this->translator->trans('false'), |
||
130 | 'nullValue' => '', |
||
131 | 'visible' => false |
||
132 | ]) |
||
133 | ->add('favorite', BoolColumn::class, [ |
||
134 | 'label' => $this->translator->trans('part.table.favorite'), |
||
135 | 'trueValue' => $this->translator->trans('true'), |
||
136 | 'falseValue' => $this->translator->trans('false'), |
||
137 | 'nullValue' => '', |
||
138 | 'visible' => false |
||
139 | ]) |
||
140 | ->add('manufacturing_status', MapColumn::class, [ |
||
141 | 'label' => $this->translator->trans('part.table.manufacturingStatus'), |
||
142 | 'visible' => false, |
||
143 | 'default' => $this->translator->trans('m_status.unknown'), |
||
144 | 'map' => [ |
||
145 | '' => $this->translator->trans('m_status.unknown'), |
||
146 | 'announced' => $this->translator->trans('m_status.announced'), |
||
147 | 'active' => $this->translator->trans('m_status.active'), |
||
148 | 'nrfnd' => $this->translator->trans('m_status.nrfnd'), |
||
149 | 'eol' => $this->translator->trans('m_status.eol'), |
||
150 | 'discontinued' => $this->translator->trans('m_status.discontinued') |
||
151 | ] |
||
152 | ]) |
||
153 | ->add('manufacturer_product_number', TextColumn::class, [ |
||
154 | 'label' => $this->translator->trans('part.table.mpn'), |
||
155 | 'visible' => false |
||
156 | ]) |
||
157 | ->add('mass', TextColumn::class, [ |
||
158 | 'label' => $this->translator->trans('part.table.mass'), |
||
159 | 'visible' => false |
||
160 | ]) |
||
161 | ->add('tags', TextColumn::class, [ |
||
162 | 'label' => $this->translator->trans('part.table.tags'), |
||
163 | 'visible' => false |
||
164 | ]) |
||
165 | |||
166 | ->addOrderBy('name') |
||
167 | ->createAdapter(ORMAdapter::class, [ |
||
168 | 'entity' => Part::class, |
||
169 | 'criteria' => [ |
||
170 | function (QueryBuilder $builder) use ($options) { |
||
171 | $this->buildCriteria($builder, $options); |
||
172 | }, |
||
173 | new SearchCriteriaProvider() |
||
174 | ] |
||
178 |