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.

AudienceVerifier::verify()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.2
cc 4
eloc 7
nc 8
nop 1
1
<?php
2
3
namespace Emarref\Jwt\Verification;
4
5
use Emarref\Jwt\Claim;
6
use Emarref\Jwt\Exception\InvalidAudienceException;
7
use Emarref\Jwt\Token;
8
9
class AudienceVerifier implements VerifierInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    private $audience;
15
16
    /**
17
     * @param string $audience
18
     */
19
    public function __construct($audience = null)
20
    {
21
        if (null !== $audience && !is_string($audience)) {
22
            throw new \InvalidArgumentException('Cannot verify invalid audience value.');
23
        }
24
25
        $this->audience = $audience;
26
    }
27
28
    /**
29
     * @param Token $token
30
     * @throws InvalidAudienceException
31
     */
32
    public function verify(Token $token)
33
    {
34
        /** @var Claim\Audience $audienceClaim */
35
        $audienceClaim = $token->getPayload()->findClaimByName(Claim\Audience::NAME);
36
37
        $audience = (null === $audienceClaim) ? null : $audienceClaim->getValue();
38
39
        if (!is_array($audience)) {
40
            $audience = [$audience];
41
        }
42
43
        if (!in_array($this->audience, $audience, true)) {
44
            throw new InvalidAudienceException;
45
        }
46
    }
47
}
48