Test Failed
Push — master ( a40e4f...7b50a6 )
by Ger
01:25
created

CredentialFactory::build()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 25
nc 1
nop 11

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace Gertoska\OAuth2Request\Credential;
4
5
/**
6
 * Class CredencialFactory
7
 * @package Gertoska\OAuth2Request\Credential
8
 */
9
class CredentialFactory
10
{
11
    /**
12
     * @param array $params
13
     *
14
     * @return Credential
15
     */
16
    public function buildFromArray(array $params): Credential
17
    {
18
        return new Credential(
19
            $params['uri'],
20
            $params['authorization'],
21
            $params['grantType'],
22
            $params['username'],
23
            $params['password'],
24
            isset($params['accessToken']) ? $params['accessToken'] : null,
25
            isset($params['tokenType']) ? $params['tokenType'] : null,
26
            isset($params['refreshToken']) ? $params['refreshToken'] : null,
27
            isset($params['expiresIn']) ? $params['expiresIn'] : null,
28
            isset($params['scope']) ? $params['scope'] : null,
29
            isset($params['obtainedIn']) ? $params['obtainedIn'] : null
30
        );
31
    }
32
}
33