| Conditions | 10 |
| Paths | 64 |
| Total Lines | 29 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 10 |
| Changes | 2 | ||
| Bugs | 0 | Features | 2 |
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 |
||
| 115 | 86 | public function toArray() { |
|
| 116 | 86 | $array = []; |
|
| 117 | |||
| 118 | 86 | if ($this->hasAtMembers()) { |
|
| 119 | 2 | $array = array_merge($array, $this->getAtMembers()); |
|
| 120 | } |
||
| 121 | 86 | if ($this->hasExtensionMembers()) { |
|
| 122 | 1 | $array = array_merge($array, $this->getExtensionMembers()); |
|
| 123 | } |
||
| 124 | 86 | if ($this->version !== null) { |
|
| 125 | 85 | $array['version'] = $this->version; |
|
| 126 | } |
||
| 127 | 86 | if ($this->extensions !== []) { |
|
| 128 | 5 | $array['ext'] = []; |
|
| 129 | 5 | foreach ($this->extensions as $extension) { |
|
| 130 | 5 | $array['ext'][] = $extension->getOfficialLink(); |
|
| 131 | } |
||
| 132 | } |
||
| 133 | 86 | if ($this->profiles !== []) { |
|
|
1 ignored issue
–
show
|
|||
| 134 | 11 | $array['profile'] = []; |
|
| 135 | 11 | foreach ($this->profiles as $profile) { |
|
| 136 | 11 | $array['profile'][] = $profile->getOfficialLink(); |
|
| 137 | } |
||
| 138 | } |
||
| 139 | 86 | if ($this->meta !== null && $this->meta->isEmpty() === false) { |
|
| 140 | 6 | $array['meta'] = $this->meta->toArray(); |
|
| 141 | } |
||
| 142 | |||
| 143 | 86 | return $array; |
|
| 144 | } |
||
| 146 |