Conditions | 11 |
Paths | 384 |
Total Lines | 23 |
Code Lines | 14 |
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 |
||
23 | public function __construct($attributes = []) |
||
24 | { |
||
25 | $attributes['orderable'] = isset($attributes['orderable']) ? $attributes['orderable'] : true; |
||
26 | $attributes['searchable'] = isset($attributes['searchable']) ? $attributes['searchable'] : true; |
||
27 | $attributes['exportable'] = isset($attributes['exportable']) ? $attributes['exportable'] : true; |
||
28 | $attributes['printable'] = isset($attributes['printable']) ? $attributes['printable'] : true; |
||
29 | $attributes['footer'] = isset($attributes['footer']) ? $attributes['footer'] : ''; |
||
30 | $attributes['attributes'] = isset($attributes['attributes']) ? $attributes['attributes'] : []; |
||
31 | |||
32 | // Allow methods override attribute value |
||
33 | foreach ($attributes as $attribute => $value) { |
||
34 | $method = 'parse' . ucfirst(strtolower($attribute)); |
||
35 | if (method_exists($this, $method)) { |
||
36 | $attributes[$attribute] = $this->$method($value); |
||
37 | } |
||
38 | } |
||
39 | |||
40 | if (! isset($attributes['name']) && isset($attributes['data'])) { |
||
41 | $attributes['name'] = $attributes['data']; |
||
42 | } |
||
43 | |||
44 | parent::__construct($attributes); |
||
45 | } |
||
46 | |||
92 |