Conditions | 1 |
Paths | 1 |
Total Lines | 52 |
Code Lines | 44 |
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 |
||
84 | |||
85 | /** |
||
86 | * @return array<string, array<string, mixed>> |
||
87 | */ |
||
88 | private function getOAuthProvidersForUrl(?AccessUrl $url): array |
||
89 | { |
||
90 | $authentication = $this->getAuthSources($url); |
||
91 | |||
92 | if (isset($authentication['oauth2'])) { |
||
93 | return $authentication['oauth2']; |
||
94 | } |
||
95 | |||
96 | return []; |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * @return array<int, string> |
||
101 | */ |
||
102 | public function getAuthSourceAuthentications(?AccessUrl $url): array |
||
103 | { |
||
104 | $authSources = $this->getAuthSources($url); |
||
105 | |||
106 | return [UserAuthSource::PLATFORM, ...array_keys($authSources)]; |
||
107 | } |
||
108 | |||
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'], |
||
163 |