Conditions | 11 |
Paths | 1024 |
Total Lines | 66 |
Code Lines | 42 |
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 |
||
103 | protected function getEditNodes() : array |
||
104 | { |
||
105 | $nodes = array(); |
||
106 | |||
107 | if ($this->security->isGranted('read', new AttachmentType())) { |
||
108 | $nodes[] = new TreeViewNode( |
||
109 | $this->translator->trans('tree.tools.edit.attachment_types'), |
||
110 | $this->urlGenerator->generate('attachment_type_new') |
||
111 | ); |
||
112 | } |
||
113 | if ($this->security->isGranted('read', new Category())) { |
||
114 | $nodes[] = new TreeViewNode( |
||
115 | $this->translator->trans('tree.tools.edit.categories'), |
||
116 | $this->urlGenerator->generate('category_new') |
||
117 | ); |
||
118 | } |
||
119 | if ($this->security->isGranted('read', new Device())) { |
||
120 | $nodes[] = new TreeViewNode( |
||
121 | $this->translator->trans('tree.tools.edit.devices'), |
||
122 | $this->urlGenerator->generate('device_new') |
||
123 | ); |
||
124 | } |
||
125 | if ($this->security->isGranted('read', new Supplier())) { |
||
126 | $nodes[] = new TreeViewNode( |
||
127 | $this->translator->trans('tree.tools.edit.suppliers'), |
||
128 | $this->urlGenerator->generate('supplier_new') |
||
129 | ); |
||
130 | } |
||
131 | if ($this->security->isGranted('read', new Manufacturer())) { |
||
132 | $nodes[] = new TreeViewNode( |
||
133 | $this->translator->trans('tree.tools.edit.manufacturer'), |
||
134 | $this->urlGenerator->generate('manufacturer_new') |
||
135 | ); |
||
136 | } |
||
137 | if ($this->security->isGranted('read', new Storelocation())) { |
||
138 | $nodes[] = new TreeViewNode( |
||
139 | $this->translator->trans('tree.tools.edit.storelocation'), |
||
140 | $this->urlGenerator->generate('store_location_new') |
||
141 | ); |
||
142 | } |
||
143 | if ($this->security->isGranted('read', new Footprint())) { |
||
144 | $nodes[] = new TreeViewNode( |
||
145 | $this->translator->trans('tree.tools.edit.footprint'), |
||
146 | $this->urlGenerator->generate('footprint_new') |
||
147 | ); |
||
148 | } |
||
149 | if ($this->security->isGranted('read', new Currency())) { |
||
150 | $nodes[] = new TreeViewNode( |
||
151 | $this->translator->trans('tree.tools.edit.currency'), |
||
152 | $this->urlGenerator->generate('currency_new') |
||
153 | ); |
||
154 | } |
||
155 | if ($this->security->isGranted('read', new MeasurementUnit())) { |
||
156 | $nodes[] = new TreeViewNode( |
||
157 | $this->translator->trans('tree.tools.edit.measurement_unit'), |
||
158 | $this->urlGenerator->generate('measurement_unit_new') |
||
159 | ); |
||
160 | } |
||
161 | if ($this->security->isGranted('create', new Part())) { |
||
162 | $nodes[] = new TreeViewNode( |
||
163 | $this->translator->trans('tree.tools.edit.part'), |
||
164 | $this->urlGenerator->generate('part_new') |
||
165 | ); |
||
166 | } |
||
167 | |||
168 | return $nodes; |
||
169 | } |
||
209 |