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.

JoseHeaderAccessor::getX509CertificateChain()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Gandung\JWT\Accessor;
4
5
use Gandung\JWT\Validator\Validator;
6
7
/**
8
 * @author Paulus Gandung Prakosa <[email protected]>
9
 */
10
class JoseHeaderAccessor implements JoseHeaderAccessorInterface
11
{
12
    /**
13
     * @var array
14
     */
15
    private $jose;
16
17
    /**
18
     * @var \Gandung\JWT\ValidatorInterface
19
     */
20
    private $validator;
21
22
    public function __construct($header)
23
    {
24
        $this->jose = $header;
25
        $this->configureValidator();
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function getAlgorithm(): string
32
    {
33
        $this->validator->validateFromArray(
0 ignored issues
show
Bug introduced by
The method validateFromArray() does not exist on Gandung\JWT\ValidatorInterface. Did you maybe mean validate()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
34
            $this->jose,
35
            new \Gandung\JWT\Validator\Constraints\Jose\Algorithm
36
        );
37
38
        return $this->jose[\Gandung\JWT\Token\Jose::ALGORITHM];
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function getJwkSetUrl(): string
45
    {
46
        $this->validator->validateFromArray(
0 ignored issues
show
Bug introduced by
The method validateFromArray() does not exist on Gandung\JWT\ValidatorInterface. Did you maybe mean validate()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
47
            $this->jose,
48
            new \Gandung\JWT\Validator\Constraints\Jose\JWKSetUrl
49
        );
50
51
        return $this->jose[\Gandung\JWT\Token\Jose::JWK_SET_URL];
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function getJsonWebKey(): string
58
    {
59
        $this->validator->validateFromArray(
0 ignored issues
show
Bug introduced by
The method validateFromArray() does not exist on Gandung\JWT\ValidatorInterface. Did you maybe mean validate()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
60
            $this->jose,
61
            new \Gandung\JWT\Validator\Constraints\Jose\JsonWebKey
62
        );
63
64
        return $this->jose[\Gandung\JWT\Token\Jose::JSON_WEB_KEY];
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70
    public function getKeyID(): string
71
    {
72
        $this->validator->validateFromArray(
0 ignored issues
show
Bug introduced by
The method validateFromArray() does not exist on Gandung\JWT\ValidatorInterface. Did you maybe mean validate()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
73
            $this->jose,
74
            new \Gandung\JWT\Validator\Constraints\Jose\KeyID
75
        );
76
77
        return $this->jose[\Gandung\JWT\Token\Jose::KEY_ID];
78
    }
79
80
    /**
81
     * {@inheritdoc}
82
     */
83
    public function getX509Url(): string
84
    {
85
        $this->validator->validateFromArray(
0 ignored issues
show
Bug introduced by
The method validateFromArray() does not exist on Gandung\JWT\ValidatorInterface. Did you maybe mean validate()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
86
            $this->jose,
87
            new \Gandung\JWT\Validator\Constraints\Jose\X509Url
88
        );
89
90
        return $this->jose[\Gandung\JWT\Token\Jose::X509_URL];
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96
    public function getX509CertificateChain(): string
97
    {
98
        $this->validator->validateFromArray(
0 ignored issues
show
Bug introduced by
The method validateFromArray() does not exist on Gandung\JWT\ValidatorInterface. Did you maybe mean validate()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
99
            $this->jose,
100
            new \Gandung\JWT\Validator\Constraints\Jose\X509CertificateChain
101
        );
102
103
        return $this->jose[\Gandung\JWT\Token\Jose::X509_CERTIFICATE_CHAIN];
104
    }
105
106
    /**
107
     * {@inheritdoc}
108
     */
109
    public function getType(): string
110
    {
111
        $this->validator->validateFromArray(
0 ignored issues
show
Bug introduced by
The method validateFromArray() does not exist on Gandung\JWT\ValidatorInterface. Did you maybe mean validate()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
112
            $this->jose,
113
            new \Gandung\JWT\Validator\Constraints\Jose\Type
114
        );
115
116
        return $this->jose[\Gandung\JWT\Token\Jose::TYPE];
117
    }
118
119
    /**
120
     * {@inheritdoc}
121
     */
122
    public function getContentType(): string
123
    {
124
        $this->validator->validateFromArray(
0 ignored issues
show
Bug introduced by
The method validateFromArray() does not exist on Gandung\JWT\ValidatorInterface. Did you maybe mean validate()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
125
            $this->jose,
126
            new \Gandung\JWT\Validator\Constraints\Jose\ContentType
127
        );
128
129
        return $this->jose[\Gandung\JWT\Token\Jose::CONTENT_TYPE];
130
    }
131
132
    /**
133
     * {@inheritdoc}
134
     */
135
    public function get(): array
136
    {
137
        return $this->jose;
138
    }
139
140
    /**
141
     * Configure validator object.
142
     *
143
     * @param array $constraints
144
     * @return void
145
     */
146
    private function configureValidator($constraints = [])
147
    {
148
        $this->validator = new Validator;
149
150
        foreach ($constraints as $v) {
151
            $this->validator->addConstraint($v);
152
        }
153
    }
154
}
155