StaticValidator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 26
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 4 2
A __construct() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
5
namespace Xervice\Service\Middleware\Security\Validator;
6
7
8
use Xervice\Service\Middleware\Security\Exception\AuthenticationFailed;
9
10
class StaticValidator implements ValidatorInterface
11
{
12
    /**
13
     * @var array
14
     */
15
    private $tokenList;
16
17
    /**
18
     * StaticTokenValidator constructor.
19
     *
20
     * @param array $tokenList
21
     */
22
    public function __construct(array $tokenList)
23
    {
24
        $this->tokenList = $tokenList;
25
    }
26
27
    /**
28
     * @param string $token
29
     *
30
     * @throws \Xervice\Service\Middleware\Security\Exception\AuthenticationFailed
31
     */
32
    public function validate(string $token): void
33
    {
34
        if (!in_array($token, $this->tokenList)) {
35
            throw new AuthenticationFailed();
36
        }
37
    }
38
}