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::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 3
eloc 10
nc 3
nop 2
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