| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 44 |
| 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 |
||
| 109 | public function getOAuthProviderOptions(string $providerType, array $config): array |
||
| 110 | { |
||
| 111 | $defaults = match ($providerType) { |
||
| 112 | 'generic' => [ |
||
| 113 | 'clientId' => $config['client_id'], |
||
| 114 | 'clientSecret' => $config['client_secret'], |
||
| 115 | 'urlAuthorize' => $config['urlAuthorize'], |
||
| 116 | 'urlAccessToken' => $config['urlAccessToken'], |
||
| 117 | 'urlResourceOwnerDetails' => $config['urlResourceOwnerDetails'], |
||
| 118 | 'accessTokenMethod' => $config['accessTokenMethod'] ?? null, |
||
| 119 | 'accessTokenResourceOwnerId' => $config['accessTokenResourceOwnerId'] ?? null, |
||
| 120 | 'scopeSeparator' => $config['scopeSeparator'] ?? null, |
||
| 121 | 'responseError' => $config['responseError'] ?? null, |
||
| 122 | 'responseCode' => $config['responseCode'] ?? null, |
||
| 123 | 'responseResourceOwnerId' => $config['responseResourceOwnerId'] ?? null, |
||
| 124 | 'scopes' => $config['scopes'] ?? null, |
||
| 125 | 'pkceMethod' => $config['pkceMethod'] ?? null, |
||
| 126 | ], |
||
| 127 | 'facebook' => [ |
||
| 128 | 'clientId' => $config['client_id'], |
||
| 129 | 'clientSecret' => $config['client_secret'], |
||
| 130 | 'graphApiVersion' => $config['graph_api_version'] ?? null, |
||
| 131 | ], |
||
| 132 | 'keycloak' => [ |
||
| 133 | 'clientId' => $config['client_id'], |
||
| 134 | 'clientSecret' => $config['client_secret'], |
||
| 135 | 'authServerUrl' => $config['auth_server_url'], |
||
| 136 | 'realm' => $config['realm'], |
||
| 137 | 'version' => $config['version'] ?? null, |
||
| 138 | 'encryptionAlgorithm' => $config['encryption_algorithm'] ?? null, |
||
| 139 | 'encryptionKeyPath' => $config['encryption_key_path'] ?? null, |
||
| 140 | 'encryptionKey' => $config['encryption_key'] ?? null, |
||
| 141 | ], |
||
| 142 | 'azure' => [ |
||
| 143 | 'clientId' => $config['client_id'], |
||
| 144 | 'clientSecret' => $config['client_secret'], |
||
| 145 | 'clientCertificatePrivateKey' => $config['client_certificate_private_key'] ?? null, |
||
| 146 | 'clientCertificateThumbprint' => $config['client_certificate_thumbprint'] ?? null, |
||
| 147 | 'urlLogin' => $config['url_login'] ?? null, |
||
| 148 | 'pathAuthorize' => $config['path_authorize'] ?? null, |
||
| 149 | 'pathToken' => $config['path_token'] ?? null, |
||
| 150 | 'scope' => $config['scope'] ?? null, |
||
| 151 | 'tenant' => $config['tenant'] ?? null, |
||
| 152 | 'urlAPI' => $config['url_api'] ?? null, |
||
| 153 | 'resource' => $config['resource'] ?? null, |
||
| 154 | 'API_VERSION' => $config['api_version'] ?? null, |
||
| 155 | 'authWithResource' => $config['auth_with_resource'] ?? null, |
||
| 156 | 'defaultEndPointVersion' => $config['default_end_point_version'] ?? null, |
||
| 157 | ], |
||
| 158 | }; |
||
| 159 | |||
| 160 | return array_filter($defaults, fn ($value) => null !== $value); |
||
| 161 | } |
||
| 177 |