Completed
Push — master ( a94a5c...e317aa )
by Florent
02:24
created

ClaimCheckerManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkClaims() 0 14 2
A getSupportedClaimCheckers() 0 8 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\ClaimChecker;
13
14
use Jose\Object\JWTInterface;
15
16
/**
17
 * Class ClaimCheckerManager
18
 */
19
class ClaimCheckerManager implements ClaimCheckerManagerInterface
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function checkClaims(JWTInterface $jwt)
25
    {
26
        $checkers = $this->getSupportedClaimCheckers();
27
        $checked_claims = [];
28
29
        foreach ($checkers as $checker) {
30
            $checked_claims = array_merge(
31
                $checked_claims,
32
                $checker->checkClaim($jwt)
33
            );
34
        }
35
36
        return $checked_claims;
37
    }
38
39
    /**
40
     * @return \Jose\ClaimChecker\ClaimCheckerInterface[]
41
     */
42
    protected function getSupportedClaimCheckers()
43
    {
44
        return [
45
            new ExpirationTimeChecker(),
46
            new IssuedAtChecker(),
47
            new NotBeforeChecker(),
48
        ];
49
    }
50
}
51