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 (#50)
by Ha
02:31
created

Keypair::populateFromArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php declare (strict_types = 1);
2
3
namespace OpenStack\Compute\v2\Models;
4
5
use OpenCloud\Common\Resource\Creatable;
6
use OpenCloud\Common\Resource\OperatorResource;
7
use OpenCloud\Common\Resource\Deletable;
8
use OpenCloud\Common\Resource\Listable;
9
use OpenCloud\Common\Resource\Retrievable;
10
use OpenCloud\Common\Transport\Utils;
11
12
/**
13
 * Represents a Compute v2 Keypair
14
 *
15
 * @property \OpenStack\Compute\v2\Api $api
16
 */
17
class Keypair extends OperatorResource implements Listable, Retrievable, Deletable, Creatable
0 ignored issues
show
Bug introduced by
There is one abstract method enumerate in this class; you could implement it, or declare this class as abstract.
Loading history...
18
{
19
    /** @var string */
20
    public $fingerprint;
21
22
    /** @var string */
23
    public $name;
24
25
    /** @var string */
26
    public $publicKey;
27
28
    /** @var  boolean */
29
    public $deleted;
30
31
    /** @var  string */
32
    public $userId;
33
34
    /** @var  string */
35
    public $id;
36
37
    /** @var \DateTimeImmutable */
38
    public $createdAt;
39
    
40
    protected $aliases = [
41
        'public_key' => 'publicKey',
42
        'user_id'    => 'userId',
43
        'created_at' => 'createdAt',
44
    ];
45
46
    protected $resourceKey = 'keypair';
47
    protected $resourcesKey = 'keypairs';
48
49
    /**
50
     * {@inheritDoc}
51
     */
52
    public function retrieve()
53
    {
54
        $response = $this->execute($this->api->getKeypair(), ['name' => (string) $this->name]);
55
        $this->populateFromResponse($response);
56
    }
57
58
    public function create(array $userOptions): Creatable
59
    {
60
        $response = $this->execute($this->api->postKeypair(), $userOptions);
61
        return $this->populateFromResponse($response);
62
    }
63
64
    /**
65
     * {@inheritDoc}
66
     */
67
    public function populateFromArray(array $array): self
68
    {
69
        return parent::populateFromArray(Utils::flattenJson($array, $this->resourceKey));
70
    }
71
72
    /**
73
     * {@inheritDoc}
74
     */
75
    public function delete()
76
    {
77
        $this->execute($this->api->deleteKeypair(), ['name' => (string) $this->name]);
78
    }
79
}
80