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