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

LoadBalancerHealthMonitor::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\Networking\v2\Models;
4
5
use OpenStack\Common\Resource\Alias;
6
use OpenStack\Common\Resource\Creatable;
7
use OpenStack\Common\Resource\Deletable;
8
use OpenStack\Common\Resource\OperatorResource;
9
use OpenStack\Common\Resource\Retrievable;
10
use OpenStack\Common\Resource\Updateable;
11
use OpenStack\Networking\v2\Api;
12
13
/**
14
 * Represents a Neutron v2 LoadBalancer Health Monitor
15
 *
16
 * @property Api $api
17
 */
18
class LoadBalancerHealthMonitor extends OperatorResource implements Creatable, Retrievable, Updateable, Deletable
19
{
20
    /**
21
     * @var string
22
     */
23
    public $id;
24
25
    /**
26
     * @var string
27
     */
28
    public $tenantId;
29
30
    /**
31
     * @var string
32
     */
33
    public $type;
34
35
    /**
36
     * @var integer
37
     */
38
    public $delay;
39
40
    /**
41
     * @var integer
42
     */
43
    public $timeout;
44
45
    /**
46
     * @var integer
47
     */
48
    public $maxRetries;
49
50
    /**
51
     * @var string
52
     */
53
    public $httpMethod;
54
55
    /**
56
     * @var string
57
     */
58
    public $urlPath;
59
60
    /**
61
     * @var string
62
     */
63
    public $expectedCodes;
64
65
    /**
66
     * @var boolean
67
     */
68
    public $adminStateUp;
69
70
    /**
71
     * @var string
72
     */
73
    public $poolId;
74
75
    /**
76
     * @var LoadBalancerPool[]
77
     */
78
    public $pools;
79
80
    /**
81
     * @var string
82
     */
83
    public $operatingStatus;
84
85
    /**
86
     * @var string
87
     */
88
    public $provisioningStatus;
89
90
    protected $resourcesKey = 'healthmonitors';
91
    protected $resourceKey = 'healthmonitor';
92
93
    protected $aliases = [
94
        'tenant_id'           => 'tenantId',
95
        'admin_state_up'      => 'adminStateUp',
96
        'max_retries'         => 'maxRetries',
97
        'http_method'         => 'httpMethod',
98
        'url_path'            => 'urlPath',
99
        'expected_codes'      => 'expectedCodes',
100
        'pool_id'             => 'poolId',
101
        'operating_status'    => 'operatingStatus',
102
        'provisioning_status' => 'provisioningStatus',
103
    ];
104
105
    /**
106
     * @inheritdoc
107
     */
108
    protected function getAliases()
109
    {
110
        $aliases = parent::getAliases();
111
        $aliases['pools'] = new Alias('pools', LoadBalancerPool::class, true);
112
        return $aliases;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $aliases; (array<*,OpenStack\Common\Resource\Alias>) is incompatible with the return type of the parent method OpenStack\Common\Resourc...actResource::getAliases of type OpenStack\Common\Resource\Alias[].

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
113
    }
114
115
    /**
116
     * {@inheritDoc}
117
     */
118
    public function create(array $userOptions): Creatable
119
    {
120
        $response = $this->execute($this->api->postLoadBalancerHealthMonitor(), $userOptions);
121
        return $this->populateFromResponse($response);
122
    }
123
124
    /**
125
     * {@inheritDoc}
126
     */
127
    public function retrieve()
128
    {
129
        $response = $this->execute($this->api->getLoadBalancerHealthMonitor(), ['id' => (string)$this->id]);
130
        $this->populateFromResponse($response);
131
    }
132
133
    /**
134
     * {@inheritDoc}
135
     */
136
    public function update()
137
    {
138
        $response = $this->executeWithState($this->api->putLoadBalancerHealthMonitor());
139
        $this->populateFromResponse($response);
140
    }
141
142
    /**
143
     * {@inheritDoc}
144
     */
145
    public function delete()
146
    {
147
        $this->executeWithState($this->api->deleteLoadBalancerHealthMonitor());
148
    }
149
}
150