Completed
Push — master ( 0f6cd0...ce5be5 )
by Florent
41:39 queued 33s
created

CheckerManager::checkJWT()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 2 Features 0
Metric Value
c 2
b 2
f 0
dl 0
loc 13
rs 9.4285
cc 2
eloc 7
nc 2
nop 1
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace Jose\Checker;
13
14
use Jose\Object\JWTInterface;
15
16
/**
17
 * Class CheckerManager.
18
 */
19
class CheckerManager implements CheckerManagerInterface
20
{
21
    /**
22
     * @var \Jose\ClaimChecker\ClaimCheckerInterface[]
23
     */
24
    private $claim_checkers = [];
25
26
    /**
27
     * @var \Jose\ClaimChecker\HeaderCheckerInterface[]
28
     */
29
    private $header_checkers = [];
30
31
    /**
32
     * ClaimCheckerManager constructor.
33
     */
34
    public function __construct()
35
    {
36
        $this->claim_checkers = [
0 ignored issues
show
Documentation Bug introduced by
It seems like array(new \Jose\Checker\...ker\NotBeforeChecker()) of type array<integer,object<Jos...r\\NotBeforeChecker>"}> is incompatible with the declared type array<integer,object<Jos...ClaimCheckerInterface>> of property $claim_checkers.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
37
            new ExpirationTimeChecker(),
38
            new IssuedAtChecker(),
39
            new NotBeforeChecker(),
40
        ];
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function checkJWT(JWTInterface $jwt)
47
    {
48
        $checked_claims = [];
49
50
        foreach ($this->claim_checkers as $claim_checker) {
51
            $checked_claims = array_merge(
52
                $checked_claims,
53
                $claim_checker->checkClaim($jwt)
54
            );
55
        }
56
57
        return $checked_claims;
58
    }
59
60
    /**
61
     * @param \Jose\ClaimChecker\ClaimCheckerInterface $claim_checker
62
     */
63
    public function addClaimChecker(ClaimCheckerInterface $claim_checker)
64
    {
65
        $this->claim_checkers[] = $claim_checker;
66
    }
67
68
    /**
69
     * @param \Jose\ClaimChecker\HeaderCheckerInterface $header_checker
70
     */
71
    public function addHeaderChecker(HeaderCheckerInterface $header_checker)
72
    {
73
        $this->header_checkers[] = $header_checker;
74
    }
75
}
76