| Conditions | 5 |
| Paths | 4 |
| Total Lines | 14 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 35 | function authenticate(ServerRequestInterface $request, array $requestData): ?ClientInterface |
||
| 36 | { |
||
| 37 | $header = $request->getHeader('Authorization')[0]; |
||
| 38 | $token = explode(' ', $header)[1] ?? null; |
||
| 39 | if ($token) { |
||
| 40 | $credentials = explode(':', base64_decode($token)); |
||
| 41 | if (count($credentials) == 2) { |
||
| 42 | $client = $this->clientStorage->get($credentials[0]); |
||
| 43 | if ($client instanceof ConfidentialClient && $client->getPassword() === $credentials[1]) { |
||
| 44 | return $client; |
||
| 45 | } |
||
| 46 | } |
||
| 47 | } |
||
| 48 | return null; |
||
| 49 | } |
||
| 50 | } |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.