| Conditions | 10 |
| Paths | 8 |
| Total Lines | 35 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 | public function convertBatchVgrToIgdb(array $data): array |
||
| 100 | { |
||
| 101 | $result = []; |
||
| 102 | |||
| 103 | if (isset($data['platforms'])) { |
||
| 104 | $result['platforms'] = []; |
||
| 105 | foreach ($data['platforms'] as $vgrId) { |
||
| 106 | $igdbId = $this->getPlatformIgdbId($vgrId); |
||
| 107 | if ($igdbId !== null) { |
||
| 108 | $result['platforms'][$vgrId] = $igdbId; |
||
| 109 | } |
||
| 110 | } |
||
| 111 | } |
||
| 112 | |||
| 113 | if (isset($data['games'])) { |
||
| 114 | $result['games'] = []; |
||
| 115 | foreach ($data['games'] as $vgrId) { |
||
| 116 | $igdbId = $this->getGameIgdbId($vgrId); |
||
| 117 | if ($igdbId !== null) { |
||
| 118 | $result['games'][$vgrId] = $igdbId; |
||
| 119 | } |
||
| 120 | } |
||
| 121 | } |
||
| 122 | |||
| 123 | if (isset($data['genres'])) { |
||
| 124 | $result['genres'] = []; |
||
| 125 | foreach ($data['genres'] as $vgrId) { |
||
| 126 | $igdbId = $this->getGenreIgdbId($vgrId); |
||
| 127 | if ($igdbId !== null) { |
||
| 128 | $result['genres'][$vgrId] = $igdbId; |
||
| 129 | } |
||
| 130 | } |
||
| 131 | } |
||
| 132 | |||
| 133 | return $result; |
||
| 134 | } |
||
| 136 |