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

AccountLinking::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 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