Conditions | 1 |
Paths | 1 |
Total Lines | 60 |
Code Lines | 39 |
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 |
||
201 | protected function initializeMappings() |
||
202 | { |
||
203 | $this->mappings['category'] = function ($value) { |
||
204 | $this->object->getProperties()->setCategory($value); |
||
205 | }; |
||
206 | $this->mappings['company'] = function ($value) { |
||
207 | $this->object->getProperties()->setCompany($value); |
||
208 | }; |
||
209 | $this->mappings['created'] = function ($value) { |
||
210 | $this->object->getProperties()->setCreated($value); |
||
211 | }; |
||
212 | $this->mappings['creator'] = function ($value) { |
||
213 | $this->object->getProperties()->setCreator($value); |
||
214 | }; |
||
215 | $this->mappings['defaultStyle'] = function ($value) { |
||
216 | $this->object->getDefaultStyle()->applyFromArray($value); |
||
217 | }; |
||
218 | $this->mappings['description'] = function ($value) { |
||
219 | $this->object->getProperties()->setDescription($value); |
||
220 | }; |
||
221 | $this->mappings['format'] = function ($value) { |
||
222 | $this->attributes['format'] = $value; |
||
223 | }; |
||
224 | $this->mappings['keywords'] = function ($value) { |
||
225 | $this->object->getProperties()->setKeywords($value); |
||
226 | }; |
||
227 | $this->mappings['lastModifiedBy'] = function ($value) { |
||
228 | $this->object->getProperties()->setLastModifiedBy($value); |
||
229 | }; |
||
230 | $this->mappings['manager'] = function ($value) { |
||
231 | $this->object->getProperties()->setManager($value); |
||
232 | }; |
||
233 | $this->mappings['modified'] = function ($value) { |
||
234 | $this->object->getProperties()->setModified($value); |
||
235 | }; |
||
236 | $this->mappings['security']['lockRevision'] = function ($value) { |
||
237 | $this->object->getSecurity()->setLockRevision($value); |
||
238 | }; |
||
239 | $this->mappings['security']['lockStructure'] = function ($value) { |
||
240 | $this->object->getSecurity()->setLockStructure($value); |
||
241 | }; |
||
242 | $this->mappings['security']['lockWindows'] = function ($value) { |
||
243 | $this->object->getSecurity()->setLockWindows($value); |
||
244 | }; |
||
245 | $this->mappings['security']['revisionsPassword'] = function ($value) { |
||
246 | $this->object->getSecurity()->setRevisionsPassword($value); |
||
247 | }; |
||
248 | $this->mappings['security']['workbookPassword'] = function ($value) { |
||
249 | $this->object->getSecurity()->setWorkbookPassword($value); |
||
250 | }; |
||
251 | $this->mappings['subject'] = function ($value) { |
||
252 | $this->object->getProperties()->setSubject($value); |
||
253 | }; |
||
254 | $this->mappings['template'] = function ($value) { |
||
255 | $this->attributes['template'] = $value; |
||
256 | }; |
||
257 | $this->mappings['title'] = function ($value) { |
||
258 | $this->object->getProperties()->setTitle($value); |
||
259 | }; |
||
260 | } |
||
261 | |||
294 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: