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 (#48)
by Jamie
02:30
created

OpenStack::blockStorageV2()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
ccs 0
cts 0
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php declare (strict_types=1);
2
3
namespace OpenStack;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\HandlerStack;
7
use OpenCloud\Common\Service\Builder;
8
use OpenCloud\Common\Transport\Utils;
9
use OpenStack\Identity\v3\Service;
10
11
/**
12
 * This class is the primary entry point for working with the SDK. It allows for the easy creation
13
 * of OpenStack services.
14
 *
15
 * @package OpenStack
16
 */
17
class OpenStack
18
{
19
    /** @var Builder */
20
    private $builder;
21
22
    /**
23
     * @param array $options User-defined options
24
     *
25
     * $options['username']         = (string)            Your OpenStack username        [REQUIRED]
26
     *         ['password']         = (string)            Your OpenStack password        [REQUIRED]
27
     *         ['tenantId']         = (string)            Your tenant ID                 [REQUIRED if tenantName omitted]
28 7
     *         ['tenantName']       = (string)            Your tenant name               [REQUIRED if tenantId omitted]
29
     *         ['authUrl']          = (string)            The Keystone URL               [REQUIRED]
30 7
     *         ['debugLog']         = (bool)              Whether to enable HTTP logging [OPTIONAL]
31 7
     *         ['logger']           = (LoggerInterface)   Must set if debugLog is true   [OPTIONAL]
32
     *         ['messageFormatter'] = (MessageFormatter)  Must set if debugLog is true   [OPTIONAL]
33
     */
34
    public function __construct(array $options = [], Builder $builder = null)
35
    {
36
        if (!isset($options['identityService'])) {
37
            $options['identityService'] = $this->getDefaultIdentityService($options);
38
        }
39
40 1
        $this->builder = $builder ?: new Builder($options, 'OpenStack');
41
    }
42 1
43 1
    /**
44
     * @param array $options
45
     *
46
     * @return Service
47
     */
48
    private function getDefaultIdentityService(array $options): Service
49
    {
50
        if (!isset($options['authUrl'])) {
51
            throw new \InvalidArgumentException("'authUrl' is a required option");
52
        }
53 1
54
        return Service::factory(new Client([
55 1
            'base_uri' => Utils::normalizeUrl($options['authUrl']),
56 1
            'handler'  => HandlerStack::create(),
57
        ]));
58
    }
59
60
    /**
61
     * Creates a new Compute v2 service.
62
     *
63
     * @param array $options Options that will be used in configuring the service.
64
     *
65
     * @return \OpenStack\Compute\v2\Service
66 1
     */
67
    public function computeV2(array $options = []): \OpenStack\Compute\v2\Service
68 1
    {
69 1
        $defaults = ['catalogName' => 'nova', 'catalogType' => 'compute'];
70
        return $this->builder->createService('Compute\\v2', array_merge($defaults, $options));
0 ignored issues
show
Documentation introduced by
array_merge($defaults, $options) is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
71
    }
72
73
    /**
74
     * Creates a new Networking v2 service.
75
     *
76
     * @param array $options Options that will be used in configuring the service.
77
     *
78
     * @return \OpenStack\Networking\v2\Service
79 1
     */
80
    public function networkingV2(array $options = []): \OpenStack\Networking\v2\Service
81 1
    {
82 1
        $defaults = ['catalogName' => 'neutron', 'catalogType' => 'network'];
83
        return $this->builder->createService('Networking\\v2', array_merge($defaults, $options));
0 ignored issues
show
Documentation introduced by
array_merge($defaults, $options) is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
84
    }
85
86
    /**
87
     * Creates a new Networking v2 Layer 3 service.
88
     *
89
     * @param array $options Options that will be used in configuring the service.
90
     *
91
     * @return \OpenStack\Networking\v2\Extensions\Layer3\Service
92 1
     */
93
    public function networkingV2ExtLayer3(array $options = []): \OpenStack\Networking\v2\Extensions\Layer3\Service
94 1
    {
95 1
        $defaults = ['catalogName' => 'neutron', 'catalogType' => 'network'];
96
        return $this->builder->createService('Networking\\v2\\Extensions\\Layer3', array_merge($defaults, $options));
0 ignored issues
show
Documentation introduced by
array_merge($defaults, $options) is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
97
    }
98
99
    /**
100
     * Creates a new Networking v2 Layer 3 service.
101
     *
102
     * @param array $options Options that will be used in configuring the service.
103
     *
104
     * @return \OpenStack\Networking\v2\Extensions\SecurityGroups\Service
105 1
     */
106
    public function networkingV2ExtSecGroups(array $options = []): \OpenStack\Networking\v2\Extensions\SecurityGroups\Service
107 1
    {
108 1
        $defaults = ['catalogName' => 'neutron', 'catalogType' => 'network'];
109
        return $this->builder->createService('Networking\\v2\\Extensions\\SecurityGroups', array_merge($defaults, $options));
0 ignored issues
show
Documentation introduced by
array_merge($defaults, $options) is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
110
    }
111
112
    /**
113
     * Creates a new Identity v2 service.
114
     *
115
     * @param array $options Options that will be used in configuring the service.
116
     *
117
     * @return \OpenStack\Identity\v2\Service
118 1
     */
119
    public function identityV2(array $options = []): \OpenStack\Identity\v2\Service
120 1
    {
121 1
        $defaults = ['catalogName' => false, 'catalogType' => false];
122
        return $this->builder->createService('Identity\\v2', array_merge($defaults, $options));
0 ignored issues
show
Documentation introduced by
array_merge($defaults, $options) is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
123
    }
124
125
    /**
126
     * Creates a new Identity v3 service.
127
     *
128
     * @param array $options Options that will be used in configuring the service.
129
     *
130
     * @return \OpenStack\Identity\v3\Service
131
     */
132
    public function identityV3(array $options = []): \OpenStack\Identity\v3\Service
133
    {
134
        $defaults = ['catalogName' => false, 'catalogType' => false];
135
        return $this->builder->createService('Identity\\v3', array_merge($defaults, $options));
0 ignored issues
show
Documentation introduced by
array_merge($defaults, $options) is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
136
    }
137
138
    /**
139
     * Creates a new Object Store v1 service.
140
     *
141
     * @param array $options Options that will be used in configuring the service.
142
     *
143
     * @return \OpenStack\ObjectStore\v1\Service
144
     */
145
    public function objectStoreV1(array $options = []): \OpenStack\ObjectStore\v1\Service
146
    {
147
        $defaults = ['catalogName' => 'swift', 'catalogType' => 'object-store'];
148
        return $this->builder->createService('ObjectStore\\v1', array_merge($defaults, $options));
0 ignored issues
show
Documentation introduced by
array_merge($defaults, $options) is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
149
    }
150
151
    /**
152
     * Creates a new Block Storage v2 service.
153
     *
154
     * @param array $options Options that will be used in configuring the service.
155
     *
156
     * @return \OpenStack\BlockStorage\v2\Service
157
     */
158
    public function blockStorageV2(array $options = []): \OpenStack\BlockStorage\v2\Service
159
    {
160
        $defaults = ['catalogName' => 'cinderv2', 'catalogType' => 'volumev2'];
161
        return $this->builder->createService('BlockStorage\\v2', array_merge($defaults, $options));
0 ignored issues
show
Documentation introduced by
array_merge($defaults, $options) is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
162
    }
163
164
    /**
165
     * Creates a new Images v2 service.
166
     *
167
     * @param array $options Options that will be used in configuring the service.
168
     *
169
     * @return \OpenStack\Images\v2\Service
170
     */
171
    public function imagesV2(array $options = []): \OpenStack\Images\v2\Service
172
    {
173
        $defaults = ['catalogName' => 'glance', 'catalogType' => 'image'];
174
        return $this->builder->createService('Images\\v2', array_merge($defaults, $options));
0 ignored issues
show
Documentation introduced by
array_merge($defaults, $options) is of type array, but the function expects a integer.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
175
    }
176
}
177