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 ( a6e2fd...77480b )
by Jamie
12s
created

Token::hasExpired()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php declare(strict_types=1);
2
3
namespace OpenStack\Identity\v2\Models;
4
5
use OpenStack\Common\Resource\Alias;
6
use OpenStack\Common\Transport\Utils;
7
use Psr\Http\Message\ResponseInterface;
8
use OpenStack\Common\Resource\OperatorResource;
9
use OpenStack\Common\Resource\ValueResource;
10
11
/**
12
 * Represents an Identity v2 Token.
13
 *
14
 * @package OpenStack\Identity\v2\Models
15
 */
16
class Token extends OperatorResource implements \OpenStack\Common\Auth\Token
17
{
18
    /** @var \DateTimeImmutable */
19
    public $issuedAt;
20
21
    /** @var string */
22
    public $id;
23
24
    /** @var \DateTimeImmutable */
25
    public $expires;
26
27
    /** @var Tenant */
28
    public $tenant;
29
30
    /**
31
     * @inheritdoc
32
     */
33
    protected function getAliases(): array
34 2
    {
35
        return parent::getAliases() + [
36 2
            'tenant'    => new Alias('tenant', Tenant::class),
37
            'expires'   => new Alias('expires', \DateTimeImmutable::class),
38 2
            'issued_at' => new Alias('issuedAt', \DateTimeImmutable::class)
39
        ];
40
    }
41 1
42
    /**
43 1
     * {@inheritDoc}
44
     */
45
    public function populateFromResponse(ResponseInterface $response): self
46 2
    {
47
        $this->populateFromArray(Utils::jsonDecode($response)['access']['token']);
48 2
49
        return $this;
50
    }
51
52
    public function getId(): string
53
    {
54
        return $this->id;
55
    }
56
57
    public function hasExpired(): bool
58
    {
59
        return $this->expires <= new \DateTimeImmutable('now', $this->expires->getTimezone());
60
    }
61
}
62