VerificationResult   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 140
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 15
dl 0
loc 140
c 0
b 0
f 0
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A setJti() 0 7 2
A getJti() 0 3 1
A getId() 0 3 1
A setAud() 0 7 2
A __construct() 0 9 1
A setLogin() 0 7 2
A getLogin() 0 3 1
A setIat() 0 3 1
A getIat() 0 3 1
A setId() 0 7 2
A getAud() 0 3 1
1
<?php
2
3
namespace JincorTech\AuthClient\Abstracts;
4
5
use InvalidArgumentException;
6
use JincorTech\AuthClient\Traits\ValidateParams;
7
8
/**
9
 * Class VerificationResult.
10
 */
11
abstract class VerificationResult
12
{
13
    use ValidateParams;
14
15
    /**
16
     * @var string
17
     */
18
    private $id;
19
20
    /**
21
     * @var string
22
     */
23
    private $login;
24
25
    /**
26
     * @var string
27
     */
28
    private $jti;
29
30
    /**
31
     * @var int
32
     */
33
    private $iat;
34
35
    /**
36
     * @var string
37
     */
38
    private $aud;
39
40
    /**
41
     * VerificationResult constructor.
42
     *
43
     * @param array $params
44
     * @throws InvalidArgumentException
45
     */
46
    public function __construct(array $params)
47
    {
48
        $this->validateParams($params, ['id', 'login', 'jti', 'iat', 'aud']);
49
50
        $this->setId($params['id']);
51
        $this->setLogin($params['login']);
52
        $this->setJti($params['jti']);
53
        $this->setIat($params['iat']);
0 ignored issues
show
Bug introduced by
It seems like $params['iat'] can also be of type string; however, parameter $iat of JincorTech\AuthClient\Ab...icationResult::setIat() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

53
        $this->setIat(/** @scrutinizer ignore-type */ $params['iat']);
Loading history...
54
        $this->setAud($params['aud']);
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    public function getId(): string
61
    {
62
        return $this->id;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getLogin(): string
69
    {
70
        return $this->login;
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getJti(): string
77
    {
78
        return $this->jti;
79
    }
80
81
    /**
82
     * @return int
83
     */
84
    public function getIat(): int
85
    {
86
        return $this->iat;
87
    }
88
89
    /**
90
     * @return string
91
     */
92
    public function getAud(): string
93
    {
94
        return $this->aud;
95
    }
96
97
    /**
98
     * @param string $id
99
     */
100
    private function setId(string $id)
101
    {
102
        if (empty($id)) {
103
            throw new InvalidArgumentException('Id value can not be empty');
104
        }
105
106
        $this->id = $id;
107
    }
108
109
    /**
110
     * @param string $login
111
     */
112
    private function setLogin(string $login)
113
    {
114
        if (empty($login)) {
115
            throw new InvalidArgumentException('Login value can not be empty');
116
        }
117
118
        $this->login = $login;
119
    }
120
121
    /**
122
     * @param string $jti
123
     */
124
    private function setJti(string $jti)
125
    {
126
        if (empty($jti)) {
127
            throw new InvalidArgumentException('Jti value can not be empty');
128
        }
129
130
        $this->jti = $jti;
131
    }
132
133
    /**
134
     * @param int $iat
135
     */
136
    private function setIat(int $iat)
137
    {
138
        $this->iat = $iat;
139
    }
140
141
    /**
142
     * @param string $aud
143
     */
144
    private function setAud(string $aud)
145
    {
146
        if (empty($aud)) {
147
            throw new InvalidArgumentException('Aud value can not be empty');
148
        }
149
150
        $this->aud = $aud;
151
    }
152
}
153