Conditions | 10 |
Paths | 32 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 10 |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
25 | 12 | public function jsonSerialize(): array |
|
26 | { |
||
27 | 12 | $data = []; |
|
28 | |||
29 | 12 | if ($this->description !== null && $this->description !== '') { |
|
30 | 2 | $data['description'] = $this->description; |
|
31 | } |
||
32 | 12 | if ($this->extend !== null && $this->extend !== []) { |
|
33 | 3 | $data['extend'] = $this->extend; |
|
34 | } |
||
35 | 12 | if ($this->extends !== null && $this->extends !== '') { |
|
36 | 2 | $data['extends'] = $this->extends; |
|
37 | } |
||
38 | 12 | if ($this->value instanceof StyleValue) { |
|
39 | 3 | $data['value'] = $this->value; |
|
40 | } |
||
41 | 12 | if ($this->values !== null && $this->values !== []) { |
|
42 | 2 | $data['values'] = $this->values; |
|
43 | } |
||
44 | |||
45 | 12 | return $data; |
|
46 | } |
||
48 |