Test Failed
Push — master ( 7b50a6...1c581a )
by Ger
02:55
created

CredentialFactory   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 47
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B buildFromArray() 0 16 7
A build() 0 27 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Gertoska\OAuth2Request\Credential;
6
7
final class CredentialFactory
8
{
9
    public function buildFromArray(array $params): Credential
10
    {
11
        return $this->build(
12
            $params['uri'],
13
            $params['authorization'],
14
            $params['grantType'],
15
            $params['username'],
16
            $params['password'],
17
            isset($params['accessToken']) ? $params['accessToken'] : null,
18
            isset($params['tokenType']) ? $params['tokenType'] : null,
19
            isset($params['refreshToken']) ? $params['refreshToken'] : null,
20
            isset($params['expiresIn']) ? $params['expiresIn'] : null,
21
            isset($params['scope']) ? $params['scope'] : null,
22
            isset($params['obtainedIn']) ? $params['obtainedIn'] : null
23
        );
24
    }
25
26
    private function build(
27
        string $uri,
28
        string $authorization,
29
        string $grantType,
30
        string $username,
31
        string $password,
32
        string $accessToken = null,
33
        string $tokenType = null,
34
        string $refreshToken = null,
35
        int $expiresIn = null,
36
        string $scope = null,
37
        int $obtainedIn = null
38
    ): Credential {
39
        return new Credential(
40
            $uri,
41
            $authorization,
42
            $grantType,
43
            $username,
44
            $password,
45
            $accessToken,
46
            $tokenType,
47
            $refreshToken,
48
            $expiresIn,
49
            $scope,
50
            $obtainedIn
51
        );
52
    }
53
}
54