CredentialFactory   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 47
ccs 26
cts 26
cp 1
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 2
    public function buildFromArray(array $params): Credential
10
    {
11 2
        return $this->build(
12 2
            $params['uri'],
13 2
            $params['authorization'],
14 2
            $params['grantType'],
15 2
            $params['username'],
16 2
            $params['password'],
17 2
            isset($params['accessToken']) ? $params['accessToken'] : null,
18 2
            isset($params['tokenType']) ? $params['tokenType'] : null,
19 2
            isset($params['refreshToken']) ? $params['refreshToken'] : null,
20 2
            isset($params['expiresIn']) ? $params['expiresIn'] : null,
21 2
            isset($params['scope']) ? $params['scope'] : null,
22 2
            isset($params['obtainedIn']) ? $params['obtainedIn'] : null
23
        );
24
    }
25
26 2
    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 2
        return new Credential(
40 2
            $uri,
41 2
            $authorization,
42 2
            $grantType,
43 2
            $username,
44 2
            $password,
45 2
            $accessToken,
46 2
            $tokenType,
47 2
            $refreshToken,
48 2
            $expiresIn,
49 2
            $scope,
50 2
            $obtainedIn
51
        );
52
    }
53
}
54