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
Pull Request — master (#159)
by Roman
01:51
created

Keypair::getAliases()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace OpenStack\Compute\v2\Models;
4
5
use OpenStack\Common\Resource\Alias;
6
use OpenStack\Common\Resource\Creatable;
7
use OpenStack\Common\Resource\OperatorResource;
8
use OpenStack\Common\Resource\Deletable;
9
use OpenStack\Common\Resource\Listable;
10
use OpenStack\Common\Resource\Retrievable;
11
use OpenStack\Common\Transport\Utils;
12
13
/**
14
 * Represents a Compute v2 Keypair
15
 *
16
 * @property \OpenStack\Compute\v2\Api $api
17
 */
18
class Keypair extends OperatorResource implements Listable, Retrievable, Deletable, Creatable
19
{
20
    /** @var string */
21
    public $fingerprint;
22
23
    /** @var string */
24
    public $name;
25
26
    /** @var string */
27
    public $publicKey;
28
29
    /** @var string */
30
    public $privateKey;
31
32
    /** @var  boolean */
33
    public $deleted;
34
35
    /** @var  string */
36
    public $userId;
37
38
    /** @var  string */
39
    public $id;
40
41
    /** @var \DateTimeImmutable */
42
    public $createdAt;
43
44
    protected $aliases = [
45
        'public_key' => 'publicKey',
46
        'private_key' => 'privateKey',
47
        'user_id'    => 'userId',
48
    ];
49
50
    protected $resourceKey = 'keypair';
51
    protected $resourcesKey = 'keypairs';
52
53
    /**
54
     * @inheritdoc
55
     */
56
    protected function getAliases(): array
57
    {
58
        $aliases = parent::getAliases();
59
        $aliases['created_at'] = new Alias('createdAt', \DateTimeImmutable::class);
60
        return $aliases;
61
    }
62
63
    /**
64
     * {@inheritDoc}
65
     */
66
    public function retrieve()
67
    {
68
        $response = $this->execute($this->api->getKeypair(), ['name' => (string) $this->name]);
69
        $this->populateFromResponse($response);
70
    }
71
72
    public function create(array $userOptions): Creatable
73
    {
74
        $response = $this->execute($this->api->postKeypair(), $userOptions);
75
        return $this->populateFromResponse($response);
76
    }
77
78
    /**
79
     * {@inheritDoc}
80
     */
81
    public function populateFromArray(array $array): self
82
    {
83
        return parent::populateFromArray(Utils::flattenJson($array, $this->resourceKey));
84
    }
85
86
    /**
87
     * {@inheritDoc}
88
     */
89
    public function delete()
90
    {
91
        $this->execute($this->api->deleteKeypair(), ['name' => (string) $this->name]);
92
    }
93
}
94