Passed
Pull Request — master (#15)
by Adam
02:48
created

Client   F

Complexity

Total Complexity 63

Size/Duplication

Total Lines 1065
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1065
rs 1.9756
c 0
b 0
f 0
wmc 63

63 Methods

Rating   Name   Duplication   Size   Complexity  
A domains() 0 7 1
A addApplicationToTeam() 0 10 1
A createRole() 0 12 1
A invitees() 0 4 1
A __construct() 0 3 1
A teams() 0 4 1
A deployCode() 0 16 1
A createTeam() 0 10 1
A deleteRole() 0 3 1
A updateRole() 0 10 1
A organizationTeams() 0 4 1
A enableLiveDev() 0 4 1
A environment() 0 7 1
A environments() 0 7 1
A organizationRoles() 0 4 1
A addQuery() 0 3 1
A permissions() 0 3 1
A environmentDatabases() 0 7 1
A deleteDomain() 0 4 1
A restoreDatabaseBackup() 0 7 1
A databaseCreate() 0 10 1
A createTeamInvite() 0 11 1
A organizationApplications() 0 4 1
A databaseBackups() 0 7 1
A createDomain() 0 11 1
A deleteMember() 0 7 1
A switchCode() 0 15 1
A applications() 0 3 1
A code() 0 7 1
A factory() 0 7 1
A databaseDelete() 0 4 1
A renameApplication() 0 15 1
A clearQuery() 0 3 1
A createOrganizationAdminInvite() 0 10 1
A enableCron() 0 7 1
A applicationInsights() 0 4 1
A createDatabaseBackup() 0 7 1
A purgeVarnishCache() 0 15 1
A createCron() 0 13 1
A deleteCron() 0 4 1
A getQuery() 0 3 1
A application() 0 7 1
A databaseCopy() 0 11 1
A disableLiveDev() 0 15 1
A servers() 0 7 1
A members() 0 4 1
A renameEnvironment() 0 15 1
A deleteTeam() 0 4 1
A databases() 0 7 1
A disableCron() 0 7 1
A databaseBackup() 0 7 1
A cron() 0 7 1
A environmentInsights() 0 4 1
A disableProductionMode() 0 7 1
A renameTeam() 0 10 1
A copyFiles() 0 10 1
A tasks() 0 7 1
A enableProductionMode() 0 7 1
A organizations() 0 3 1
A logstream() 0 3 1
A drushAliases() 0 3 1
A teamApplications() 0 4 1
A crons() 0 7 1

How to fix   Complexity   

Complex Class

Complex classes like Client often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Client, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace AcquiaCloudApi\CloudApi;
4
5
use AcquiaCloudApi\Response\ApplicationResponse;
6
use AcquiaCloudApi\Response\ApplicationsResponse;
7
use AcquiaCloudApi\Response\BackupResponse;
8
use AcquiaCloudApi\Response\BackupsResponse;
9
use AcquiaCloudApi\Response\BranchesResponse;
10
use AcquiaCloudApi\Response\CronResponse;
11
use AcquiaCloudApi\Response\CronsResponse;
12
use AcquiaCloudApi\Response\DatabasesResponse;
13
use AcquiaCloudApi\Response\DomainsResponse;
14
use AcquiaCloudApi\Response\EnvironmentResponse;
15
use AcquiaCloudApi\Response\EnvironmentsResponse;
16
use AcquiaCloudApi\Response\InsightsResponse;
17
use AcquiaCloudApi\Response\InvitationsResponse;
18
use AcquiaCloudApi\Response\LogstreamResponse;
19
use AcquiaCloudApi\Response\MembersResponse;
20
use AcquiaCloudApi\Response\OperationResponse;
21
use AcquiaCloudApi\Response\OrganizationsResponse;
22
use AcquiaCloudApi\Response\PermissionsResponse;
23
use AcquiaCloudApi\Response\RolesResponse;
24
use AcquiaCloudApi\Response\ServersResponse;
25
use AcquiaCloudApi\Response\TasksResponse;
26
use AcquiaCloudApi\Response\TeamsResponse;
27
use Psr\Http\Message\StreamInterface;
28
29
/**
30
 * Class Client
31
 * @package AcquiaCloudApi\CloudApi
32
 */
33
class Client implements ClientInterface
34
{
35
    /** @var ConnectorInterface The API connector. */
36
    protected $connector;
37
38
    /** @var array Query strings to be applied to the request. */
39
    protected $query = [];
40
41
    /**
42
     * Client constructor.
43
     *
44
     * @param ConnectorInterface $connector
45
     */
46
    public function __construct(ConnectorInterface $connector)
47
    {
48
        $this->connector = $connector;
49
    }
50
51
    /**
52
     * Client factory method for instantiating .
53
     *
54
     * @param ConnectorInterface $connector
55
     *
56
     * @return static
57
     */
58
    public static function factory(ConnectorInterface $connector)
59
    {
60
        $client = new static(
61
            $connector
62
        );
63
64
        return $client;
65
    }
66
67
    /**
68
     * Get query from Client.
69
     *
70
     * @return array
71
     */
72
    public function getQuery()
73
    {
74
        return $this->query;
75
    }
76
77
    /**
78
     * Clear query.
79
     */
80
    public function clearQuery()
81
    {
82
        $this->query = [];
83
    }
84
85
    /**
86
     * Add a query parameter to filter results.
87
     *
88
     * @param string $name
89
     * @param string $value
90
     */
91
    public function addQuery($name, $value)
92
    {
93
        $this->query = array_merge_recursive($this->query, [$name => $value]);
94
    }
95
96
    /**
97
     * Shows all applications.
98
     *
99
     * @return ApplicationsResponse
100
     */
101
    public function applications()
102
    {
103
        return new ApplicationsResponse($this->connector->request('get', '/applications', $this->query));
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...cations', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $applications of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

103
        return new ApplicationsResponse(/** @scrutinizer ignore-type */ $this->connector->request('get', '/applications', $this->query));
Loading history...
104
    }
105
106
    /**
107
     * Shows information about an application.
108
     *
109
     * @param string $applicationUuid
110
     * @return ApplicationResponse
111
     */
112
    public function application($applicationUuid)
113
    {
114
        return new ApplicationResponse(
115
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...tionUuid, $this->query) can also be of type array; however, parameter $application of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

115
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
116
                'get',
117
                "/applications/${applicationUuid}",
118
                $this->query
119
            )
120
        );
121
    }
122
123
    /**
124
     * Renames an application.
125
     *
126
     * @param string $applicationUuid
127
     * @param string $name
128
     * @return OperationResponse
129
     */
130
    public function renameApplication($applicationUuid, $name)
131
    {
132
133
        $options = [
134
            'form_params' => [
135
                'name' => $name,
136
            ],
137
        ];
138
139
        return new OperationResponse(
140
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$options, $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

140
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
141
                'put',
142
                "/applications/${applicationUuid}",
143
                $options,
144
                $this->query
145
            )
146
        );
147
    }
148
149
    /**
150
     * Shows all code branches and tags in an application.
151
     *
152
     * @param string $applicationUuid
153
     * @return BranchesResponse
154
     */
155
    public function code($applicationUuid)
156
    {
157
        return new BranchesResponse(
158
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques....'/code', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $branches of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

158
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
159
                'get',
160
                "/applications/${applicationUuid}/code",
161
                $this->query
162
            )
163
        );
164
    }
165
166
    /**
167
     * Shows all databases in an application.
168
     *
169
     * @param string $applicationUuid
170
     * @return DatabasesResponse
171
     */
172
    public function databases($applicationUuid)
173
    {
174
        return new DatabasesResponse(
175
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...tabases', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $databases of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

175
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
176
                'get',
177
                "/applications/${applicationUuid}/databases",
178
                $this->query
179
            )
180
        );
181
    }
182
183
    /**
184
     * Shows all databases in an environment.
185
     *
186
     * @param string $environmentUuid
187
     * @return DatabasesResponse
188
     */
189
    public function environmentDatabases($environmentUuid)
190
    {
191
        return new DatabasesResponse(
192
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...tabases', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $databases of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

192
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
193
                'get',
194
                "/environments/${environmentUuid}/databases",
195
                $this->query
196
            )
197
        );
198
    }
199
200
    /**
201
     * Copies a database from an environment to an environment.
202
     *
203
     * @param string $environmentFromUuid
204
     * @param string $dbName
205
     * @param string $environmentToUuid
206
     * @return OperationResponse
207
     */
208
    public function databaseCopy($environmentFromUuid, $dbName, $environmentToUuid)
209
    {
210
        $options = [
211
            'form_params' => [
212
                'name' => $dbName,
213
                'source' => $environmentFromUuid,
214
            ],
215
        ];
216
217
        return new OperationResponse(
218
            $this->connector->request('post', "/environments/${environmentToUuid}/databases", $this->query, $options)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

218
            /** @scrutinizer ignore-type */ $this->connector->request('post', "/environments/${environmentToUuid}/databases", $this->query, $options)
Loading history...
219
        );
220
    }
221
222
    /**
223
     * Create a new database.
224
     *
225
     * @param string $applicationUuid
226
     * @param string $name
227
     * @return OperationResponse
228
     */
229
    public function databaseCreate($applicationUuid, $name)
230
    {
231
        $options = [
232
            'form_params' => [
233
                'name' => $name,
234
            ],
235
        ];
236
237
        return new OperationResponse(
238
            $this->connector->request('post', "/applications/${applicationUuid}/databases", $this->query, $options)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

238
            /** @scrutinizer ignore-type */ $this->connector->request('post', "/applications/${applicationUuid}/databases", $this->query, $options)
Loading history...
239
        );
240
    }
241
242
    /**
243
     * Delete a database.
244
     *
245
     * @param string $applicationUuid
246
     * @param string $name
247
     * @return OperationResponse
248
     */
249
    public function databaseDelete($applicationUuid, $name)
250
    {
251
        return new OperationResponse(
252
            $this->connector->request('post', "/applications/${applicationUuid}/databases/${name}", $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques.../'.$name, $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

252
            /** @scrutinizer ignore-type */ $this->connector->request('post', "/applications/${applicationUuid}/databases/${name}", $this->query)
Loading history...
253
        );
254
    }
255
256
    /**
257
     * Backup a database.
258
     *
259
     * @param string $environmentUuid
260
     * @param string $dbName
261
     * @return OperationResponse
262
     */
263
    public function createDatabaseBackup($environmentUuid, $dbName)
264
    {
265
        return new OperationResponse(
266
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...backups', $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

266
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
267
                'post',
268
                "/environments/${environmentUuid}/databases/${dbName}/backups",
269
                $this->query
270
            )
271
        );
272
    }
273
274
    /**
275
     * Shows all database backups in an environment.
276
     *
277
     * @param string $environmentUuid
278
     * @param string $dbName
279
     * @return BackupsResponse
280
     */
281
    public function databaseBackups($environmentUuid, $dbName)
282
    {
283
        return new BackupsResponse(
284
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...backups', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $backups of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

284
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
285
                'get',
286
                "/environments/${environmentUuid}/databases/${dbName}/backups",
287
                $this->query
288
            )
289
        );
290
    }
291
292
    /**
293
     * Gets information about a database backup.
294
     *
295
     * @param string $environmentUuid
296
     * @param int    $backupId
297
     * @return BackupResponse
298
     */
299
    public function databaseBackup($environmentUuid, $backupId)
300
    {
301
        return new BackupResponse(
302
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...backupId, $this->query) can also be of type array; however, parameter $backup of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

302
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
303
                'get',
304
                "/environments/${environmentUuid}/database-backups/${backupId}",
305
                $this->query
306
            )
307
        );
308
    }
309
310
    /**
311
     * Restores a database backup to a database in an environment.
312
     *
313
     * @param string $environmentUuid
314
     * @param int    $backupId
315
     * @return OperationResponse
316
     */
317
    public function restoreDatabaseBackup($environmentUuid, $backupId)
318
    {
319
        return new OperationResponse(
320
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...restore', $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

320
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
321
                'post',
322
                "/environments/${environmentUuid}/database-backups/${backupId}/actions/restore",
323
                $this->query
324
            )
325
        );
326
    }
327
328
    /**
329
     * Copies files from an environment to another environment.
330
     *
331
     * @param string $environmentUuidFrom
332
     * @param string $environmentUuidTo
333
     * @return OperationResponse
334
     */
335
    public function copyFiles($environmentUuidFrom, $environmentUuidTo)
336
    {
337
        $options = [
338
            'form_params' => [
339
                'source' => $environmentUuidFrom,
340
            ],
341
        ];
342
343
        return new OperationResponse(
344
            $this->connector->request('post', "/environments/${environmentUuidTo}/files", $this->query, $options)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

344
            /** @scrutinizer ignore-type */ $this->connector->request('post', "/environments/${environmentUuidTo}/files", $this->query, $options)
Loading history...
345
        );
346
    }
347
348
    /**
349
     * Deploys a code branch/tag to an environment.
350
     *
351
     * @param string $environmentUuid
352
     * @param string $branch
353
     * @return OperationResponse
354
     */
355
    public function switchCode($environmentUuid, $branch)
356
    {
357
358
        $options = [
359
            'form_params' => [
360
                'branch' => $branch,
361
            ],
362
        ];
363
364
        return new OperationResponse(
365
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

365
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
366
                'post',
367
                "/environments/${environmentUuid}/code/actions/switch",
368
                $this->query,
369
                $options
370
            )
371
        );
372
    }
373
374
    /**
375
     * Deploys code from one environment to another environment.
376
     *
377
     * @param string $environmentFromUuid
378
     * @param string $environmentToUuid
379
     * @param string $commitMessage
380
     */
381
    public function deployCode($environmentFromUuid, $environmentToUuid, $commitMessage = null)
382
    {
383
384
        $options = [
385
            'form_params' => [
386
                'source' => $environmentFromUuid,
387
                'message' => $commitMessage,
388
            ],
389
        ];
390
391
        return new OperationResponse(
392
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

392
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
393
                'post',
394
                "/environments/${environmentToUuid}/code",
395
                $this->query,
396
                $options
397
            )
398
        );
399
    }
400
401
    /**
402
     * Shows all domains on an environment.
403
     *
404
     * @param string $environmentUuid
405
     * @return DomainsResponse
406
     */
407
    public function domains($environmentUuid)
408
    {
409
        return new DomainsResponse(
410
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...domains', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $domains of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

410
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
411
                'get',
412
                "/environments/${environmentUuid}/domains",
413
                $this->query
414
            )
415
        );
416
    }
417
418
    /**
419
     * Adds a domain to an environment.
420
     *
421
     * @param string $environmentUuid
422
     * @param string $hostname
423
     * @return OperationResponse
424
     */
425
    public function createDomain($environmentUuid, $hostname)
426
    {
427
428
        $options = [
429
            'form_params' => [
430
                'hostname' => $hostname,
431
            ],
432
        ];
433
434
        return new OperationResponse(
435
            $this->connector->request('post', "/environments/${environmentUuid}/domains", $this->query, $options)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

435
            /** @scrutinizer ignore-type */ $this->connector->request('post', "/environments/${environmentUuid}/domains", $this->query, $options)
Loading history...
436
        );
437
    }
438
439
    /**
440
     * Deletes a domain from an environment.
441
     *
442
     * @param string $environmentUuid
443
     * @param string $domain
444
     * @return OperationResponse
445
     */
446
    public function deleteDomain($environmentUuid, $domain)
447
    {
448
        return new OperationResponse(
449
            $this->connector->request('delete', "/environments/${environmentUuid}/domains/${domain}", $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques....$domain, $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

449
            /** @scrutinizer ignore-type */ $this->connector->request('delete', "/environments/${environmentUuid}/domains/${domain}", $this->query)
Loading history...
450
        );
451
    }
452
453
    /**
454
     * Purges varnish for selected domains in an environment.
455
     *
456
     * @param string $environmentUuid
457
     * @param array  $domains
458
     * @return OperationResponse
459
     */
460
    public function purgeVarnishCache($environmentUuid, array $domains)
461
    {
462
463
        $options = [
464
            'form_params' => [
465
                'domains' => $domains,
466
            ],
467
        ];
468
469
        return new OperationResponse(
470
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

470
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
471
                'post',
472
                "/environments/${environmentUuid}/domains/actions/clear-varnish",
473
                $this->query,
474
                $options
475
            )
476
        );
477
    }
478
479
    /**
480
     * Shows all tasks in an application.
481
     *
482
     * @param string $applicationUuid
483
     * @return TasksResponse
484
     */
485
    public function tasks($applicationUuid)
486
    {
487
        return new TasksResponse(
488
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...'/tasks', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $tasks of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

488
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
489
                'get',
490
                "/applications/${applicationUuid}/tasks",
491
                $this->query
492
            )
493
        );
494
    }
495
496
    /**
497
     * Shows all environments in an application.
498
     *
499
     * @param string $applicationUuid
500
     * @return EnvironmentsResponse
501
     */
502
    public function environments($applicationUuid)
503
    {
504
        return new EnvironmentsResponse(
505
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...onments', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $environments of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

505
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
506
                'get',
507
                "/applications/${applicationUuid}/environments",
508
                $this->query
509
            )
510
        );
511
    }
512
513
    /**
514
     * Gets information about an environment.
515
     *
516
     * @param string $environmentUuid
517
     * @return EnvironmentResponse
518
     */
519
    public function environment($environmentUuid)
520
    {
521
        return new EnvironmentResponse(
522
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...mentUuid, $this->query) can also be of type array; however, parameter $environment of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

522
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
523
                'get',
524
                "/environments/${environmentUuid}",
525
                $this->query
526
            )
527
        );
528
    }
529
530
    /**
531
     * Renames an environment.
532
     *
533
     * @param string $environmentUuid
534
     * @param string $label
535
     * @return OperationResponse
536
     */
537
    public function renameEnvironment($environmentUuid, $label)
538
    {
539
540
        $options = [
541
            'form_params' => [
542
                'label' => $label,
543
            ],
544
        ];
545
546
        return new OperationResponse(
547
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

547
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
548
                'post',
549
                "/environments/${environmentUuid}/actions/change-label",
550
                $this->query,
551
                $options
552
            )
553
        );
554
    }
555
556
    /**
557
     * Show all servers associated with an environment.
558
     *
559
     * @param string $environmentUuid
560
     * @return ServersResponse
561
     */
562
    public function servers($environmentUuid)
563
    {
564
        return new ServersResponse(
565
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...servers', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $servers of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

565
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
566
                'get',
567
                "/environments/${environmentUuid}/servers",
568
                $this->query
569
            )
570
        );
571
    }
572
573
    /**
574
     * Enable livedev mode for an environment.
575
     *
576
     * @param string $environmentUuid
577
     * @return OperationResponse
578
     */
579
    public function enableLiveDev($environmentUuid)
580
    {
581
        return new OperationResponse(
582
            $this->connector->request('post', "/environments/${environmentUuid}/livedev/actions/enable", $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques.../enable', $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

582
            /** @scrutinizer ignore-type */ $this->connector->request('post', "/environments/${environmentUuid}/livedev/actions/enable", $this->query)
Loading history...
583
        );
584
    }
585
586
    /**
587
     * Disable livedev mode for an environment.
588
     *
589
     * @param string $environmentUuid
590
     * @return OperationResponse
591
     */
592
    public function disableLiveDev($environmentUuid)
593
    {
594
595
        $options = [
596
            'form_params' => [
597
                'discard' => 1,
598
            ],
599
        ];
600
601
        return new OperationResponse(
602
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

602
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
603
                'post',
604
                "/environments/${environmentUuid}/livedev/actions/disable",
605
                $this->query,
606
                $options
607
            )
608
        );
609
    }
610
611
    /**
612
     * Enable production mode for an environment.
613
     *
614
     * @param string $environmentUuid
615
     * @return OperationResponse
616
     */
617
    public function enableProductionMode($environmentUuid)
618
    {
619
        return new OperationResponse(
620
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques.../enable', $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

620
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
621
                'post',
622
                "/environments/${environmentUuid}/production-mode/actions/enable",
623
                $this->query
624
            )
625
        );
626
    }
627
628
    /**
629
     * Disable production mode for an environment.
630
     *
631
     * @param string $environmentUuid
632
     * @return OperationResponse
633
     */
634
    public function disableProductionMode($environmentUuid)
635
    {
636
        return new OperationResponse(
637
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...disable', $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

637
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
638
                'post',
639
                "/environments/${environmentUuid}/production-mode/actions/disable",
640
                $this->query
641
            )
642
        );
643
    }
644
645
    /**
646
     * Show all cron tasks for an environment.
647
     *
648
     * @param string $environmentUuid The environment ID
649
     * @return CronsResponse
650
     */
651
    public function crons($environmentUuid)
652
    {
653
        return new CronsResponse(
654
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...'/crons', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $crons of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

654
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
655
                'get',
656
                "/environments/${environmentUuid}/crons",
657
                $this->query
658
            )
659
        );
660
    }
661
662
    /**
663
     * Get information about a cron task.
664
     *
665
     * @param string $environmentUuid The environment ID
666
     * @param int    $cronId
667
     * @return CronResponse
668
     */
669
    public function cron($environmentUuid, $cronId)
670
    {
671
        return new CronResponse(
672
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques....$cronId, $this->query) can also be of type array; however, parameter $cron of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

672
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
673
                'get',
674
                "/environments/${environmentUuid}/crons/${cronId}",
675
                $this->query
676
            )
677
        );
678
    }
679
680
    /**
681
     * Add a cron task.
682
     *
683
     * @param string $environmentUuid
684
     * @param string $command
685
     * @param string $frequency
686
     * @param string $label
687
     * @return OperationResponse
688
     */
689
    public function createCron($environmentUuid, $command, $frequency, $label)
690
    {
691
692
        $options = [
693
            'form_params' => [
694
                'command' => $command,
695
                'frequency' => $frequency,
696
                'label' => $label,
697
            ],
698
        ];
699
700
        return new OperationResponse(
701
            $this->connector->request('post', "/environments/${environmentUuid}/crons", $this->query, $options)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

701
            /** @scrutinizer ignore-type */ $this->connector->request('post', "/environments/${environmentUuid}/crons", $this->query, $options)
Loading history...
702
        );
703
    }
704
705
    /**
706
     * Delete a cron task.
707
     *
708
     * @param string $environmentUuid
709
     * @param int    $cronId
710
     * @return OperationResponse
711
     */
712
    public function deleteCron($environmentUuid, $cronId)
713
    {
714
        return new OperationResponse(
715
            $this->connector->request('delete', "/environments/${environmentUuid}/crons/${cronId}", $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques....$cronId, $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

715
            /** @scrutinizer ignore-type */ $this->connector->request('delete', "/environments/${environmentUuid}/crons/${cronId}", $this->query)
Loading history...
716
        );
717
    }
718
719
    /**
720
     * Disable a cron task.
721
     *
722
     * @param string $environmentUuid
723
     * @param int    $cronId
724
     * @return OperationResponse
725
     */
726
    public function disableCron($environmentUuid, $cronId)
727
    {
728
        return new OperationResponse(
729
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...disable', $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

729
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
730
                'post',
731
                "/environments/${environmentUuid}/crons/${cronId}/actions/disable",
732
                $this->query
733
            )
734
        );
735
    }
736
737
    /**
738
     * Enable a cron task.
739
     *
740
     * @param string $environmentUuid
741
     * @param int    $cronId
742
     * @return OperationResponse
743
     */
744
    public function enableCron($environmentUuid, $cronId)
745
    {
746
        return new OperationResponse(
747
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques.../enable', $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

747
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
748
                'post',
749
                "/environments/${environmentUuid}/crons/${cronId}/actions/enable",
750
                $this->query
751
            )
752
        );
753
    }
754
755
    /**
756
     * Provides an archived set of files for Acquia Drush aliases.
757
     *
758
     * @return StreamInterface
759
     */
760
    public function drushAliases()
761
    {
762
        return $this->connector->request('get', '/account/drush-aliases/download', $this->query);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->connector-...ownload', $this->query) also could return the type array which is incompatible with the documented return type Psr\Http\Message\StreamInterface.
Loading history...
763
    }
764
765
    /**
766
     * Show insights data from an application.
767
     *
768
     * @param string $applicationUuid
769
     * @return InsightsResponse
770
     */
771
    public function applicationInsights($applicationUuid)
772
    {
773
        return new InsightsResponse(
774
            $this->connector->request('get', "/applications/${applicationUuid}/insight", $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...insight', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $insights of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

774
            /** @scrutinizer ignore-type */ $this->connector->request('get', "/applications/${applicationUuid}/insight", $this->query)
Loading history...
775
        );
776
    }
777
778
    /**
779
     * Show insights data from a specific environment.
780
     *
781
     * @param string $environmentUuid
782
     * @return InsightsResponse
783
     */
784
    public function environmentInsights($environmentUuid)
785
    {
786
        return new InsightsResponse(
787
            $this->connector->request('get', "/environments/${environmentUuid}/insight", $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...insight', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $insights of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

787
            /** @scrutinizer ignore-type */ $this->connector->request('get', "/environments/${environmentUuid}/insight", $this->query)
Loading history...
788
        );
789
    }
790
791
    /**
792
     * Show all organizations.
793
     *
794
     * @return OrganizationsResponse
795
     */
796
    public function organizations()
797
    {
798
        return new OrganizationsResponse($this->connector->request('get', '/organizations', $this->query));
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...zations', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $organizations of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

798
        return new OrganizationsResponse(/** @scrutinizer ignore-type */ $this->connector->request('get', '/organizations', $this->query));
Loading history...
799
    }
800
801
    /**
802
     * Show all applications in an organisation.
803
     *
804
     * @param string $organizationUuid
805
     *
806
     * @return ApplicationsResponse
807
     */
808
    public function organizationApplications($organizationUuid)
809
    {
810
        return new ApplicationsResponse(
811
            $this->connector->request('get', "/organizations/${organizationUuid}/applications", $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...cations', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $applications of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

811
            /** @scrutinizer ignore-type */ $this->connector->request('get', "/organizations/${organizationUuid}/applications", $this->query)
Loading history...
812
        );
813
    }
814
815
    /**
816
     * Show all roles in an organization.
817
     *
818
     * @param string $organizationUuid
819
     * @return RolesResponse
820
     */
821
    public function organizationRoles($organizationUuid)
822
    {
823
        return new RolesResponse(
824
            $this->connector->request('get', "/organizations/${organizationUuid}/roles", $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...'/roles', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $roles of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

824
            /** @scrutinizer ignore-type */ $this->connector->request('get', "/organizations/${organizationUuid}/roles", $this->query)
Loading history...
825
        );
826
    }
827
828
    /**
829
     * Update the permissions associated with a role.
830
     *
831
     * @param string $roleUuid
832
     * @param array  $permissions
833
     * @return OperationResponse
834
     */
835
    public function updateRole($roleUuid, array $permissions)
836
    {
837
        $options = [
838
            'form_params' => [
839
                'permissions' => $permissions,
840
            ],
841
        ];
842
843
        return new OperationResponse(
844
            $this->connector->request('put', "/roles/${roleUuid}", $this->query, $options)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

844
            /** @scrutinizer ignore-type */ $this->connector->request('put', "/roles/${roleUuid}", $this->query, $options)
Loading history...
845
        );
846
    }
847
848
    /**
849
     * Create a new role.
850
     *
851
     * @param string      $organizationUuid
852
     * @param string      $name
853
     * @param array       $permissions
854
     * @param null|string $description
855
     * @return OperationResponse
856
     */
857
    public function createRole($organizationUuid, $name, array $permissions, $description = null)
858
    {
859
        $options = [
860
            'form_params' => [
861
                'name' => $name,
862
                'permissions' => $permissions,
863
                'description' => $description,
864
            ],
865
        ];
866
867
        return new OperationResponse(
868
            $this->connector->request('post', "/organizations/${organizationUuid}/roles", $this->query, $options)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

868
            /** @scrutinizer ignore-type */ $this->connector->request('post', "/organizations/${organizationUuid}/roles", $this->query, $options)
Loading history...
869
        );
870
    }
871
872
    /**
873
     * Delete a role.
874
     *
875
     * @param string $roleUuid
876
     * @return OperationResponse
877
     */
878
    public function deleteRole($roleUuid)
879
    {
880
        return new OperationResponse($this->connector->request('delete', "/roles/${roleUuid}", $this->query));
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...roleUuid, $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

880
        return new OperationResponse(/** @scrutinizer ignore-type */ $this->connector->request('delete', "/roles/${roleUuid}", $this->query));
Loading history...
881
    }
882
883
    /**
884
     * Show all teams in an organization.
885
     *
886
     * @param string $organizationUuid
887
     * @return TeamsResponse
888
     */
889
    public function organizationTeams($organizationUuid)
890
    {
891
        return new TeamsResponse(
892
            $this->connector->request('get', "/organizations/${organizationUuid}/teams", $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...'/teams', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $teams of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

892
            /** @scrutinizer ignore-type */ $this->connector->request('get', "/organizations/${organizationUuid}/teams", $this->query)
Loading history...
893
        );
894
    }
895
896
    /**
897
     * Show all teams.
898
     *
899
     * @return TeamsResponse
900
     */
901
    public function teams()
902
    {
903
        return new TeamsResponse(
904
            $this->connector->request('get', '/teams', $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...'/teams', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $teams of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

904
            /** @scrutinizer ignore-type */ $this->connector->request('get', '/teams', $this->query)
Loading history...
905
        );
906
    }
907
908
    /**
909
     * Rename an existing team.
910
     *
911
     * @param string $teamUuid
912
     * @param string $name
913
     * @return OperationResponse
914
     */
915
    public function renameTeam($teamUuid, $name)
916
    {
917
        $options = [
918
            'form_params' => [
919
                'name' => $name,
920
            ],
921
        ];
922
923
        return new OperationResponse(
924
            $this->connector->request('put', "/teams/${teamUuid}", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques.../'.$teamUuid, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

924
            /** @scrutinizer ignore-type */ $this->connector->request('put', "/teams/${teamUuid}", $options)
Loading history...
925
        );
926
    }
927
928
    /**
929
     * Create a new team.
930
     *
931
     * @param string $organizationUuid
932
     * @param string $name
933
     * @return OperationResponse
934
     */
935
    public function createTeam($organizationUuid, $name)
936
    {
937
        $options = [
938
            'form_params' => [
939
                'name' => $name,
940
            ],
941
        ];
942
943
        return new OperationResponse(
944
            $this->connector->request('post', "/organizations/${organizationUuid}/teams", $this->query, $options)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

944
            /** @scrutinizer ignore-type */ $this->connector->request('post', "/organizations/${organizationUuid}/teams", $this->query, $options)
Loading history...
945
        );
946
    }
947
948
    /**
949
     * Delete a team.
950
     *
951
     * @param string $teamUuid
952
     * @return OperationResponse
953
     */
954
    public function deleteTeam($teamUuid)
955
    {
956
        return new OperationResponse(
957
            $this->connector->request('delete', "/teams/${teamUuid}", $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...teamUuid, $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

957
            /** @scrutinizer ignore-type */ $this->connector->request('delete', "/teams/${teamUuid}", $this->query)
Loading history...
958
        );
959
    }
960
961
    /**
962
     * Add an application to a team.
963
     *
964
     * @param string $teamUuid
965
     * @param string $applicationUuid
966
     * @return OperationResponse
967
     */
968
    public function addApplicationToTeam($teamUuid, $applicationUuid)
969
    {
970
        $options = [
971
            'form_params' => [
972
                'uuid' => $applicationUuid,
973
            ],
974
        ];
975
976
        return new OperationResponse(
977
            $this->connector->request('post', "/teams/${teamUuid}/applications", $this->query, $options)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

977
            /** @scrutinizer ignore-type */ $this->connector->request('post', "/teams/${teamUuid}/applications", $this->query, $options)
Loading history...
978
        );
979
    }
980
981
    /**
982
     * Invites a user to join a team.
983
     *
984
     * @param string $teamUuid
985
     * @param string $email
986
     * @param array  $roles
987
     * @return OperationResponse
988
     */
989
    public function createTeamInvite($teamUuid, $email, $roles)
990
    {
991
        $options = [
992
            'form_params' => [
993
                'email' => $email,
994
                'roles' => $roles
995
            ],
996
        ];
997
998
        return new OperationResponse(
999
            $this->connector->request('post', "/teams/${teamUuid}/invites", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...d.'/invites', $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

999
            /** @scrutinizer ignore-type */ $this->connector->request('post', "/teams/${teamUuid}/invites", $options)
Loading history...
1000
        );
1001
    }
1002
1003
    /**
1004
     * Invites a user to become admin of an organization.
1005
     *
1006
     * @param string $organizationUuid
1007
     * @param string $email
1008
     * @return OperationResponse
1009
     */
1010
    public function createOrganizationAdminInvite($organizationUuid, $email)
1011
    {
1012
        $options = [
1013
            'form_params' => [
1014
                'email' => $email,
1015
            ],
1016
        ];
1017
1018
        return new OperationResponse(
1019
            $this->connector->request('post', "/teams/${organizationUuid}/invites", $this->query, $options)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...$this->query, $options) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1019
            /** @scrutinizer ignore-type */ $this->connector->request('post', "/teams/${organizationUuid}/invites", $this->query, $options)
Loading history...
1020
        );
1021
    }
1022
1023
    /**
1024
     * Show all applications associated with a team.
1025
     *
1026
     * @param string $teamUuid
1027
     * @return ApplicationsResponse
1028
     */
1029
    public function teamApplications($teamUuid)
1030
    {
1031
        return new ApplicationsResponse(
1032
            $this->connector->request('get', "/teams/${teamUuid}/applications", $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...cations', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $applications of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1032
            /** @scrutinizer ignore-type */ $this->connector->request('get', "/teams/${teamUuid}/applications", $this->query)
Loading history...
1033
        );
1034
    }
1035
1036
    /**
1037
     * Show all members of an organisation.
1038
     *
1039
     * @param string $organizationUuid
1040
     * @return MembersResponse
1041
     */
1042
    public function members($organizationUuid)
1043
    {
1044
        return new MembersResponse(
1045
            $this->connector->request('get', "/organizations/${organizationUuid}/members", $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...members', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $members of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1045
            /** @scrutinizer ignore-type */ $this->connector->request('get', "/organizations/${organizationUuid}/members", $this->query)
Loading history...
1046
        );
1047
    }
1048
1049
    /**
1050
     * Show all members invited to an organisation.
1051
     *
1052
     * @param string $organizationUuid
1053
     * @return InvitationsResponse
1054
     */
1055
    public function invitees($organizationUuid)
1056
    {
1057
        return new InvitationsResponse(
1058
            $this->connector->request('get', "/organizations/${organizationUuid}/team-invites", $this->query)
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...invites', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $invitations of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1058
            /** @scrutinizer ignore-type */ $this->connector->request('get', "/organizations/${organizationUuid}/team-invites", $this->query)
Loading history...
1059
        );
1060
    }
1061
1062
    /**
1063
     * Delete a member from an organisation.
1064
     *
1065
     * @param string $organizationUuid
1066
     * @param string $memberUuid
1067
     * @return OperationResponse
1068
     */
1069
    public function deleteMember($organizationUuid, $memberUuid)
1070
    {
1071
        return new OperationResponse(
1072
            $this->connector->request(
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...mberUuid, $this->query) can also be of type array; however, parameter $operation of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1072
            /** @scrutinizer ignore-type */ $this->connector->request(
Loading history...
1073
                'delete',
1074
                "/organizations/${organizationUuid}/members/${memberUuid}",
1075
                $this->query
1076
            )
1077
        );
1078
    }
1079
1080
    /**
1081
     * Show all available permissions.
1082
     *
1083
     * @return PermissionsResponse
1084
     */
1085
    public function permissions()
1086
    {
1087
        return new PermissionsResponse($this->connector->request('get', '/permissions', $this->query));
0 ignored issues
show
Bug introduced by
It seems like $this->connector->reques...issions', $this->query) can also be of type object and Psr\Http\Message\StreamInterface; however, parameter $permissions of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1087
        return new PermissionsResponse(/** @scrutinizer ignore-type */ $this->connector->request('get', '/permissions', $this->query));
Loading history...
1088
    }
1089
1090
    /**
1091
     * Returns logstream WSS streams.
1092
     *
1093
     * @return LogstreamResponse
1094
     */
1095
    public function logstream($environmentUuid)
1096
    {
1097
        return new LogstreamResponse($this->connector->request('get', "/environments/${environmentUuid}/logstream"));
0 ignored issues
show
Bug Best Practice introduced by
The expression return new AcquiaCloudAp...mentUuid.'/logstream')) returns the type AcquiaCloudApi\Response\LogstreamResponse which is incompatible with the return type mandated by AcquiaCloudApi\CloudApi\...tInterface::logstream() of AcquiaCloudApi\CloudApi\LogstreamResponse.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
Bug introduced by
It seems like $this->connector->reques...nmentUuid.'/logstream') can also be of type array; however, parameter $logstream of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

1097
        return new LogstreamResponse(/** @scrutinizer ignore-type */ $this->connector->request('get', "/environments/${environmentUuid}/logstream"));
Loading history...
1098
    }
1099
}
1100