| Conditions | 3 |
| Paths | 3 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | 10 | public function createFromArray(array $config) |
|
| 15 | { |
||
| 16 | $requiredParams = [ |
||
| 17 | 10 | 'client_credentials_identifier', |
|
| 18 | 'client_credentials_secret', |
||
| 19 | 'temporary_credentials_uri', |
||
| 20 | 'authorization_uri', |
||
| 21 | 'token_credentials_uri', |
||
| 22 | ]; |
||
| 23 | |||
| 24 | 10 | foreach ($requiredParams as $param) { |
|
| 25 | 10 | if (! isset($config[$param])) { |
|
| 26 | 10 | throw new InvalidArgumentException("Missing OAuth1 client configuration: {$param}."); |
|
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | 5 | $clientCredentials = new ClientCredentials( |
|
| 31 | 5 | $config['client_credentials_identifier'], |
|
| 32 | 5 | $config['client_credentials_secret'] |
|
| 33 | ); |
||
| 34 | |||
| 35 | 5 | $uriConfig = new UriConfig($config, new UriParser()); |
|
| 36 | |||
| 37 | 5 | return new Config($clientCredentials, $uriConfig); |
|
| 38 | } |
||
| 40 |