| Total Complexity | 3 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class ClientCredentials implements GrantTypeInterface |
||
| 8 | { |
||
| 9 | private ClientInterface $client; |
||
| 10 | |||
| 11 | private array $config; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @throws \InvalidArgumentException |
||
| 15 | */ |
||
| 16 | 10 | public function __construct(ClientInterface $client, array $config) |
|
| 17 | { |
||
| 18 | 10 | $this->client = $client; |
|
| 19 | |||
| 20 | 10 | $required = ['client_id', 'client_secret', 'token_uri']; |
|
| 21 | |||
| 22 | 10 | if ($missing = array_diff($required, array_keys($config))) { |
|
| 23 | 1 | $message = 'Parameters: '.implode(', ', $missing).' are required.'; |
|
| 24 | |||
| 25 | 1 | throw new \InvalidArgumentException($message, 0); |
|
| 26 | } |
||
| 27 | |||
| 28 | 9 | $this->config = array_merge([ |
|
| 29 | 9 | 'scope' => '', |
|
| 30 | 9 | ], $config); |
|
| 31 | } |
||
| 32 | |||
| 33 | 4 | public function getToken(?string $refreshToken = null): array |
|
| 48 | } |
||
| 49 | } |
||
| 50 |