| Conditions | 12 |
| Paths | 9 |
| Total Lines | 33 |
| 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 |
||
| 61 | public function getUserInfo(User $user, UserAccount $userAccount, array $claims, array $claimLocales): array |
||
| 62 | { |
||
| 63 | $result = []; |
||
| 64 | $claimLocales[] = null; |
||
| 65 | foreach ($claims as $claimName => $config) { |
||
| 66 | if ($this->has($claimName)) { |
||
| 67 | $claim = $this->get($claimName); |
||
| 68 | foreach ($claimLocales as $claimLocale) { |
||
| 69 | if ($claim->isAvailableForUserAccount($user, $userAccount, $claimLocale)) { |
||
| 70 | $value = $claim->getForUserAccount($user, $userAccount, $claimLocale); |
||
| 71 | switch (true) { |
||
| 72 | case \is_array($config) && \array_key_exists('value', $config): |
||
| 73 | if ($claim === $config['value']) { |
||
| 74 | $result[$claimName] = $value; |
||
| 75 | } |
||
| 76 | |||
| 77 | break; |
||
| 78 | case \is_array($config) && \array_key_exists('values', $config) && \is_array($config['values']): |
||
| 79 | if (\in_array($claim, $config['values'], true)) { |
||
| 80 | $result[$claimName] = $value; |
||
| 81 | } |
||
| 82 | |||
| 83 | break; |
||
| 84 | default: |
||
| 85 | $result[$claimName] = $value; |
||
| 86 | } |
||
| 87 | } |
||
| 88 | } |
||
| 89 | } |
||
| 90 | } |
||
| 91 | |||
| 92 | return $result; |
||
| 93 | } |
||
| 94 | } |
||
| 95 |