GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — develop (#32)
by Boy
06:10
created

AuthnContextClass   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
c 2
b 0
f 0
lcom 2
cbo 1
dl 0
loc 72
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 3
A getTypes() 0 7 1
A isIdentifiedBy() 0 4 1
A isOfType() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
namespace Surfnet\StepupBundle\Value;
4
5
use Surfnet\StepupBundle\Exception\InvalidArgumentException;
6
7
final class AuthnContextClass
8
{
9
    const TYPE_GATEWAY='gateway';
10
    const TYPE_SECOND_FACTOR_ONLY='second-factor-only';
11
12
    /**
13
     * @var string
14
     */
15
    private $identifier;
16
17
    /**
18
     * @var string
19
     */
20
    private $type;
21
22
    /**
23
     * AuthnContextClassRef constructor.
24
     * @param string $identifier
25
     * @param string $type
26
     */
27
    public function __construct($identifier, $type)
28
    {
29
        if (!is_string($identifier)) {
30
            throw InvalidArgumentException::invalidType('string', 'identifier', $identifier);
31
        }
32
33
        $this->identifier = $identifier;
34
35
        if (!in_array($type, [self::TYPE_GATEWAY, self::TYPE_SECOND_FACTOR_ONLY])) {
36
            throw InvalidArgumentException::invalidType(
37
              'AuthnContextClassRef class constant',
38
              'type',
39
              $type
40
            );
41
        }
42
43
        $this->type = $type;
44
    }
45
46
    public static function getTypes()
47
    {
48
        return [
49
            static::TYPE_GATEWAY,
50
            static::TYPE_SECOND_FACTOR_ONLY,
51
        ];
52
    }
53
54
    /**
55
     * @param string $authnContextClassRef
56
     */
57
    public function isIdentifiedBy($authnContextClassRef)
58
    {
59
        return $this->identifier === $authnContextClassRef;
60
    }
61
62
    /**
63
     * @param $type
64
     * @return bool
65
     */
66
    public function isOfType($type)
67
    {
68
        return $this->type === $type;
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function __toString()
75
    {
76
        return  $this->identifier;
77
    }
78
}
79