ConfigFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 29
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
B createFromArray() 0 24 3
1
<?php
2
3
namespace Risan\OAuth1\Config;
4
5
use InvalidArgumentException;
6
use Risan\OAuth1\Request\UriParser;
7
use Risan\OAuth1\Credentials\ClientCredentials;
8
9
class ConfigFactory implements ConfigFactoryInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
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
    }
39
}
40