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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 46
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAliases() 0 8 1
A populateFromResponse() 0 6 1
A getId() 0 4 1
A hasExpired() 0 4 1
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