Passed
Push — master ( 0e21f4...195aeb )
by Romain
39s
created

AccountLinking   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 60
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getStatus() 0 4 1
A hasAuthorizationCode() 0 4 1
A getAuthorizationCode() 0 4 1
A create() 0 6 1
1
<?php
2
namespace Kerox\Messenger\Model\Callback;
3
4
class AccountLinking
5
{
6
7
    /**
8
     * @var string
9
     */
10
    protected $status;
11
12
    /**
13
     * @var null|string
14
     */
15
    protected $authorizationCode;
16
17
    /**
18
     * AccountLinking constructor.
19
     *
20
     * @param string $status
21
     * @param string|null $authorizationCode
22
     */
23 2
    public function __construct(string $status, string $authorizationCode = null)
24
    {
25 2
        $this->status = $status;
26 2
        $this->authorizationCode = $authorizationCode;
27 2
    }
28
29
    /**
30
     * @return string
31
     */
32 1
    public function getStatus(): string
33
    {
34 1
        return $this->status;
35
    }
36
37
    /**
38
     * @return bool
39
     */
40 1
    public function hasAuthorizationCode(): bool
41
    {
42 1
        return $this->authorizationCode !== null;
43
    }
44
45
    /**
46
     * @return null|string
47
     */
48 1
    public function getAuthorizationCode()
49
    {
50 1
        return $this->authorizationCode;
51
    }
52
53
    /**
54
     * @param array $payload
55
     * @return static
56
     */
57 1
    public static function create(array $payload)
58
    {
59 1
        $authorizationCode = $payload['authorization_code'] ?? null;
60
61 1
        return new static($payload['status'], $authorizationCode);
62
    }
63
}
64