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:48
created

Keypair   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 2
cbo 2
dl 0
loc 60
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A retrieve() 0 5 1
A create() 0 5 1
A populateFromArray() 0 4 1
A delete() 0 4 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
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 \DateTimeImmutable */
35
    public $createdAt;
36
    
37
    protected $aliases = [
38
        'public_key' => 'publicKey',
39
        'user_id'    => 'userId',
40
        'created_at' => 'createdAt',
41
    ];
42
43
    protected $resourceKey = 'keypair';
44
    protected $resourcesKey = 'keypairs';
45
46
    /**
47
     * {@inheritDoc}
48
     */
49
    public function retrieve()
50
    {
51
        $response = $this->execute($this->api->getKeypair(), ['name' => (string) $this->name]);
52
        $this->populateFromResponse($response);
53
    }
54
55
    public function create(array $userOptions): Creatable
56
    {
57
        $response = $this->execute($this->api->postKeypair(), $userOptions);
58
        return $this->populateFromResponse($response);
59
    }
60
61
    /**
62
     * {@inheritDoc}
63
     */
64
    public function populateFromArray(array $array): self
65
    {
66
        return parent::populateFromArray(Utils::flattenJson($array, $this->resourceKey));
67
    }
68
69
    /**
70
     * {@inheritDoc}
71
     */
72
    public function delete()
73
    {
74
        $this->execute($this->api->deleteKeypair(), ['name' => (string) $this->name]);
75
    }
76
}
77