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
Push — master ( 59f4b4...e271c1 )
by Joni
03:51
created

ReferenceTimeValidation::validateWithContext()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 4
nop 1
crap 4
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sop\JWX\JWT\Claim\Feature;
6
7
use Sop\JWX\JWT\ValidationContext;
8
9
/**
10
 * Trait for claims using reference time as a validation constraint.
11
 */
12
trait ReferenceTimeValidation
13
{
14
    /**
15
     * Validate the claim against given constraint.
16
     *
17
     * @param mixed $constraint
18
     *
19
     * @return bool
20
     */
21
    abstract public function validate($constraint): bool;
22
23
    /**
24
     * Override default Claim validation.
25
     *
26
     * Uses reference time of the validation context as a constraint.
27
     *
28
     * @see \Sop\JWX\JWT\Claim\Claim::validateWithContext()
29
     *
30
     * @param ValidationContext $ctx
31
     *
32
     * @return bool
33
     */
34 17
    public function validateWithContext(ValidationContext $ctx): bool
35
    {
36 17
        if ($ctx->hasReferenceTime()) {
37
            // try to validate with leeway added
38 11
            if ($this->validate($ctx->referenceTime() + $ctx->leeway())) {
39 5
                return true;
40
            }
41
            // try to validate with leeway substracted
42 10
            if ($this->validate($ctx->referenceTime() - $ctx->leeway())) {
43 5
                return true;
44
            }
45 5
            return false;
46
        }
47 6
        return true;
48
    }
49
}
50