Completed
Pull Request — master (#34)
by Adam
08:58
created

Environments   B

Complexity

Total Complexity 44

Size/Duplication

Total Lines 820
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 44
eloc 211
dl 0
loc 820
rs 8.8798
c 0
b 0
f 0

44 Methods

Rating   Name   Duplication   Size   Complexity  
A enableProductionMode() 0 6 1
A modifyEnvironment() 0 12 1
A __construct() 0 3 1
A purgeVarnishCache() 0 14 1
A databaseCopy() 0 11 1
A createDomain() 0 11 1
A createDatabaseBackup() 0 6 1
A getDomain() 0 6 1
A getEnvironment() 0 6 1
A disableLiveDev() 0 14 1
A createCron() 0 13 1
A restoreDatabaseBackup() 0 6 1
A deleteDomain() 0 4 1
A getServers() 0 6 1
A getCron() 0 6 1
A getSslCertificates() 0 6 1
A getDomains() 0 6 1
A getDatabaseBackups() 0 6 1
A switchCode() 0 14 1
A getDatabases() 0 6 1
A deployCode() 0 15 1
A enableCron() 0 6 1
A getDatabaseBackup() 0 6 1
A getLogstream() 0 4 1
A renameEnvironment() 0 14 1
A disableCron() 0 6 1
A copyFiles() 0 10 1
A deleteCron() 0 4 1
A disableProductionMode() 0 6 1
A getCrons() 0 6 1
A enableLiveDev() 0 4 1
A getInsights() 0 4 1
A getSslCertificate() 0 6 1
A deactivateSslCertificate() 0 6 1
A createLogDestination() 0 15 1
A updateLogDestination() 0 18 1
A disableLogDestination() 0 6 1
A deleteSslCertificate() 0 4 1
A createSslCertificate() 0 16 1
A getLogDestinations() 0 6 1
A deleteLogDestination() 0 4 1
A getLogDestination() 0 6 1
A activateSslCertificate() 0 6 1
A enableLogDestination() 0 6 1

How to fix   Complexity   

Complex Class

Complex classes like Environments 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 Environments, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Connector\ClientInterface;
6
use AcquiaCloudApi\Response\EnvironmentResponse;
7
use AcquiaCloudApi\Response\EnvironmentsResponse;
8
use AcquiaCloudApi\Response\DatabasesResponse;
9
use AcquiaCloudApi\Response\CronsResponse;
10
use AcquiaCloudApi\Response\CronResponse;
11
use AcquiaCloudApi\Response\CertificatesResponse;
12
use AcquiaCloudApi\Response\CertificateResponse;
13
use AcquiaCloudApi\Response\BackupsResponse;
14
use AcquiaCloudApi\Response\BackupResponse;
15
use AcquiaCloudApi\Response\DomainsResponse;
16
use AcquiaCloudApi\Response\DomainResponse;
17
use AcquiaCloudApi\Response\InsightsResponse;
18
use AcquiaCloudApi\Response\ServersResponse;
19
use AcquiaCloudApi\Response\OperationResponse;
20
use AcquiaCloudApi\Response\LogstreamResponse;
21
use AcquiaCloudApi\Response\LogForwardingDestinationsResponse;
22
use AcquiaCloudApi\Response\LogForwardingDestinationResponse;
23
24
/**
25
 * Class Client
26
 * @package AcquiaCloudApi\CloudApi
27
 */
28
class Environments implements CloudApi
29
{
30
31
    /** @var ClientInterface The API client. */
32
    protected $client;
33
34
    /**
35
     * Client constructor.
36
     *
37
     * @param ClientInterface $client
38
     */
39
    public function __construct(ClientInterface $client)
40
    {
41
        $this->client = $client;
42
    }
43
44
    /**
45
     * Shows all databases in an environment.
46
     *
47
     * @param string $environmentUuid
48
     * @return DatabasesResponse
49
     */
50
    public function getDatabases($environmentUuid)
51
    {
52
        return new DatabasesResponse(
53
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...nmentUuid.'/databases') can also be of type Psr\Http\Message\StreamInterface and object; 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

53
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
54
                'get',
55
                "/environments/${environmentUuid}/databases"
56
            )
57
        );
58
    }
59
60
    /**
61
     * Copies a database from an environment to an environment.
62
     *
63
     * @param string $environmentFromUuid
64
     * @param string $dbName
65
     * @param string $environmentToUuid
66
     * @return OperationResponse
67
     */
68
    public function databaseCopy($environmentFromUuid, $dbName, $environmentToUuid)
69
    {
70
        $options = [
71
            'form_params' => [
72
                'name' => $dbName,
73
                'source' => $environmentFromUuid,
74
            ],
75
        ];
76
77
        return new OperationResponse(
78
            $this->client->request('post', "/environments/${environmentToUuid}/databases", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...'/databases', $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

78
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentToUuid}/databases", $options)
Loading history...
79
        );
80
    }
81
82
    /**
83
     * Backup a database.
84
     *
85
     * @param string $environmentUuid
86
     * @param string $dbName
87
     * @return OperationResponse
88
     */
89
    public function createDatabaseBackup($environmentUuid, $dbName)
90
    {
91
        return new OperationResponse(
92
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...s/'.$dbName.'/backups') 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

92
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
93
                'post',
94
                "/environments/${environmentUuid}/databases/${dbName}/backups"
95
            )
96
        );
97
    }
98
99
    /**
100
     * Shows all database backups in an environment.
101
     *
102
     * @param string $environmentUuid
103
     * @param string $dbName
104
     * @return BackupsResponse
105
     */
106
    public function getDatabaseBackups($environmentUuid, $dbName)
107
    {
108
        return new BackupsResponse(
109
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...s/'.$dbName.'/backups') can also be of type Psr\Http\Message\StreamInterface and object; 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

109
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
110
                'get',
111
                "/environments/${environmentUuid}/databases/${dbName}/backups"
112
            )
113
        );
114
    }
115
116
    /**
117
     * Gets information about a database backup.
118
     *
119
     * @param string $environmentUuid
120
     * @param string $dbName
121
     * @param int    $backupId
122
     * @return BackupResponse
123
     */
124
    public function getDatabaseBackup($environmentUuid, $dbName, $backupId)
125
    {
126
        return new BackupResponse(
127
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('....'/backups/'.$backupId) 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

127
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
128
                'get',
129
                "/environments/${environmentUuid}/databases/${dbName}/backups/${backupId}"
130
            )
131
        );
132
    }
133
134
    /**
135
     * Restores a database backup to a database in an environment.
136
     *
137
     * @param string $environmentUuid
138
     * @param string $dbName
139
     * @param int    $backupId
140
     * @return OperationResponse
141
     */
142
    public function restoreDatabaseBackup($environmentUuid, $dbName, $backupId)
143
    {
144
        return new OperationResponse(
145
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...pId.'/actions/restore') 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

145
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
146
                'post',
147
                "/environments/${environmentUuid}/databases/${dbName}/backups/${backupId}/actions/restore"
148
            )
149
        );
150
    }
151
152
    /**
153
     * Copies files from an environment to another environment.
154
     *
155
     * @param string $environmentUuidFrom
156
     * @param string $environmentUuidTo
157
     * @return OperationResponse
158
     */
159
    public function copyFiles($environmentUuidFrom, $environmentUuidTo)
160
    {
161
        $options = [
162
            'form_params' => [
163
                'source' => $environmentUuidFrom,
164
            ],
165
        ];
166
167
        return new OperationResponse(
168
            $this->client->request('post', "/environments/${environmentUuidTo}/files", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...dTo.'/files', $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

168
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuidTo}/files", $options)
Loading history...
169
        );
170
    }
171
172
    /**
173
     * Deploys a code branch/tag to an environment.
174
     *
175
     * @param string $environmentUuid
176
     * @param string $branch
177
     * @return OperationResponse
178
     */
179
    public function switchCode($environmentUuid, $branch)
180
    {
181
182
        $options = [
183
            'form_params' => [
184
                'branch' => $branch,
185
            ],
186
        ];
187
188
        return new OperationResponse(
189
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ions/switch', $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

189
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
190
                'post',
191
                "/environments/${environmentUuid}/code/actions/switch",
192
                $options
193
            )
194
        );
195
    }
196
197
    /**
198
     * Deploys code from one environment to another environment.
199
     *
200
     * @param string $environmentFromUuid
201
     * @param string $environmentToUuid
202
     * @param string $commitMessage
203
     */
204
    public function deployCode($environmentFromUuid, $environmentToUuid, $commitMessage = null)
205
    {
206
207
        $options = [
208
            'form_params' => [
209
                'source' => $environmentFromUuid,
210
                'message' => $commitMessage,
211
            ],
212
        ];
213
214
        return new OperationResponse(
215
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...Uuid.'/code', $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

215
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
216
                'post',
217
                "/environments/${environmentToUuid}/code",
218
                $options
219
            )
220
        );
221
    }
222
223
    /**
224
     * Shows all domains on an environment.
225
     *
226
     * @param string $environmentUuid
227
     * @return DomainsResponse
228
     */
229
    public function getDomains($environmentUuid)
230
    {
231
        return new DomainsResponse(
232
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ronmentUuid.'/domains') can also be of type Psr\Http\Message\StreamInterface and object; 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

232
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
233
                'get',
234
                "/environments/${environmentUuid}/domains"
235
            )
236
        );
237
    }
238
239
    /**
240
     * Return details about a domain.
241
     *
242
     * @param string $environmentUuid
243
     * @param string $domain
244
     * @return DomainResponse
245
     */
246
    public function getDomain($environmentUuid, $domain)
247
    {
248
        return new DomainResponse(
249
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...id.'/domains/'.$domain) can also be of type array; however, parameter $domain 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

249
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
250
                'get',
251
                "/environments/${environmentUuid}/domains/${domain}"
252
            )
253
        );
254
    }
255
256
    /**
257
     * Adds a domain to an environment.
258
     *
259
     * @param string $environmentUuid
260
     * @param string $hostname
261
     * @return OperationResponse
262
     */
263
    public function createDomain($environmentUuid, $hostname)
264
    {
265
266
        $options = [
267
            'form_params' => [
268
                'hostname' => $hostname,
269
            ],
270
        ];
271
272
        return new OperationResponse(
273
            $this->client->request('post', "/environments/${environmentUuid}/domains", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...d.'/domains', $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

273
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuid}/domains", $options)
Loading history...
274
        );
275
    }
276
277
    /**
278
     * Deletes a domain from an environment.
279
     *
280
     * @param string $environmentUuid
281
     * @param string $domain
282
     * @return OperationResponse
283
     */
284
    public function deleteDomain($environmentUuid, $domain)
285
    {
286
        return new OperationResponse(
287
            $this->client->request('delete', "/environments/${environmentUuid}/domains/${domain}")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...id.'/domains/'.$domain) 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

287
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/environments/${environmentUuid}/domains/${domain}")
Loading history...
288
        );
289
    }
290
291
    /**
292
     * Purges varnish for selected domains in an environment.
293
     *
294
     * @param string $environmentUuid
295
     * @param array  $domains
296
     * @return OperationResponse
297
     */
298
    public function purgeVarnishCache($environmentUuid, array $domains)
299
    {
300
301
        $options = [
302
            'form_params' => [
303
                'domains' => $domains,
304
            ],
305
        ];
306
307
        return new OperationResponse(
308
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ear-varnish', $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

308
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
309
                'post',
310
                "/environments/${environmentUuid}/domains/actions/clear-varnish",
311
                $options
312
            )
313
        );
314
    }
315
316
    /**
317
     * Gets information about an environment.
318
     *
319
     * @param string $environmentUuid
320
     * @return EnvironmentResponse
321
     */
322
    public function getEnvironment($environmentUuid)
323
    {
324
        return new EnvironmentResponse(
325
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...nts/'.$environmentUuid) 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

325
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
326
                'get',
327
                "/environments/${environmentUuid}"
328
            )
329
        );
330
    }
331
332
    /**
333
     * Modifies configuration settings for an environment.
334
     *
335
     * @param string $environmentUuid
336
     * @param array $config
337
     * @return OperationResponse
338
     */
339
    public function modifyEnvironment($environmentUuid, array $config)
340
    {
341
342
        $options = [
343
          'form_params' => $config,
344
        ];
345
346
        return new OperationResponse(
347
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ironmentUuid, $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

347
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
348
                'put',
349
                "/environments/${environmentUuid}",
350
                $options
351
            )
352
        );
353
    }
354
355
    /**
356
     * Renames an environment.
357
     *
358
     * @param string $environmentUuid
359
     * @param string $label
360
     * @return OperationResponse
361
     */
362
    public function renameEnvironment($environmentUuid, $label)
363
    {
364
365
        $options = [
366
            'form_params' => [
367
                'label' => $label,
368
            ],
369
        ];
370
371
        return new OperationResponse(
372
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...hange-label', $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

372
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
373
                'post',
374
                "/environments/${environmentUuid}/actions/change-label",
375
                $options
376
            )
377
        );
378
    }
379
380
    /**
381
     * Show all servers associated with an environment.
382
     *
383
     * @param string $environmentUuid
384
     * @return ServersResponse
385
     */
386
    public function getServers($environmentUuid)
387
    {
388
        return new ServersResponse(
389
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ronmentUuid.'/servers') can also be of type Psr\Http\Message\StreamInterface and object; 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

389
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
390
                'get',
391
                "/environments/${environmentUuid}/servers"
392
            )
393
        );
394
    }
395
396
    /**
397
     * Enable livedev mode for an environment.
398
     *
399
     * @param string $environmentUuid
400
     * @return OperationResponse
401
     */
402
    public function enableLiveDev($environmentUuid)
403
    {
404
        return new OperationResponse(
405
            $this->client->request('post', "/environments/${environmentUuid}/livedev/actions/enable")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ivedev/actions/enable') 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

405
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuid}/livedev/actions/enable")
Loading history...
406
        );
407
    }
408
409
    /**
410
     * Disable livedev mode for an environment.
411
     *
412
     * @param string $environmentUuid
413
     * @return OperationResponse
414
     */
415
    public function disableLiveDev($environmentUuid)
416
    {
417
418
        $options = [
419
            'form_params' => [
420
                'discard' => 1,
421
            ],
422
        ];
423
424
        return new OperationResponse(
425
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ons/disable', $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

425
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
426
                'post',
427
                "/environments/${environmentUuid}/livedev/actions/disable",
428
                $options
429
            )
430
        );
431
    }
432
433
    /**
434
     * Enable production mode for an environment.
435
     *
436
     * @param string $environmentUuid
437
     * @return OperationResponse
438
     */
439
    public function enableProductionMode($environmentUuid)
440
    {
441
        return new OperationResponse(
442
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...n-mode/actions/enable') 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

442
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
443
                'post',
444
                "/environments/${environmentUuid}/production-mode/actions/enable"
445
            )
446
        );
447
    }
448
449
    /**
450
     * Disable production mode for an environment.
451
     *
452
     * @param string $environmentUuid
453
     * @return OperationResponse
454
     */
455
    public function disableProductionMode($environmentUuid)
456
    {
457
        return new OperationResponse(
458
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...-mode/actions/disable') 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

458
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
459
                'post',
460
                "/environments/${environmentUuid}/production-mode/actions/disable"
461
            )
462
        );
463
    }
464
465
    /**
466
     * Show all cron tasks for an environment.
467
     *
468
     * @param string $environmentUuid The environment ID
469
     * @return CronsResponse
470
     */
471
    public function getCrons($environmentUuid)
472
    {
473
        return new CronsResponse(
474
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...vironmentUuid.'/crons') can also be of type Psr\Http\Message\StreamInterface and object; 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

474
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
475
                'get',
476
                "/environments/${environmentUuid}/crons"
477
            )
478
        );
479
    }
480
481
    /**
482
     * Get information about a cron task.
483
     *
484
     * @param string $environmentUuid The environment ID
485
     * @param int    $cronId
486
     * @return CronResponse
487
     */
488
    public function getCron($environmentUuid, $cronId)
489
    {
490
        return new CronResponse(
491
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...Uuid.'/crons/'.$cronId) 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

491
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
492
                'get',
493
                "/environments/${environmentUuid}/crons/${cronId}"
494
            )
495
        );
496
    }
497
498
    /**
499
     * Add a cron task.
500
     *
501
     * @param string $environmentUuid
502
     * @param string $command
503
     * @param string $frequency
504
     * @param string $label
505
     * @return OperationResponse
506
     */
507
    public function createCron($environmentUuid, $command, $frequency, $label)
508
    {
509
510
        $options = [
511
            'form_params' => [
512
                'command' => $command,
513
                'frequency' => $frequency,
514
                'label' => $label,
515
            ],
516
        ];
517
518
        return new OperationResponse(
519
            $this->client->request('post', "/environments/${environmentUuid}/crons", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...uid.'/crons', $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

519
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuid}/crons", $options)
Loading history...
520
        );
521
    }
522
523
    /**
524
     * Delete a cron task.
525
     *
526
     * @param string $environmentUuid
527
     * @param int    $cronId
528
     * @return OperationResponse
529
     */
530
    public function deleteCron($environmentUuid, $cronId)
531
    {
532
        return new OperationResponse(
533
            $this->client->request('delete', "/environments/${environmentUuid}/crons/${cronId}")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...Uuid.'/crons/'.$cronId) 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

533
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/environments/${environmentUuid}/crons/${cronId}")
Loading history...
534
        );
535
    }
536
537
    /**
538
     * Disable a cron task.
539
     *
540
     * @param string $environmentUuid
541
     * @param int    $cronId
542
     * @return OperationResponse
543
     */
544
    public function disableCron($environmentUuid, $cronId)
545
    {
546
        return new OperationResponse(
547
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...nId.'/actions/disable') 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->client->request(
Loading history...
548
                'post',
549
                "/environments/${environmentUuid}/crons/${cronId}/actions/disable"
550
            )
551
        );
552
    }
553
554
    /**
555
     * Enable a cron task.
556
     *
557
     * @param string $environmentUuid
558
     * @param int    $cronId
559
     * @return OperationResponse
560
     */
561
    public function enableCron($environmentUuid, $cronId)
562
    {
563
        return new OperationResponse(
564
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...onId.'/actions/enable') 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

564
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
565
                'post',
566
                "/environments/${environmentUuid}/crons/${cronId}/actions/enable"
567
            )
568
        );
569
    }
570
571
    /**
572
     * Show insights data from a specific environment.
573
     *
574
     * @param string $environmentUuid
575
     * @return InsightsResponse
576
     */
577
    public function getInsights($environmentUuid)
578
    {
579
        return new InsightsResponse(
580
            $this->client->request('get', "/environments/${environmentUuid}/insight")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ronmentUuid.'/insight') can also be of type Psr\Http\Message\StreamInterface and object; 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

580
            /** @scrutinizer ignore-type */ $this->client->request('get', "/environments/${environmentUuid}/insight")
Loading history...
581
        );
582
    }
583
584
    /**
585
     * Returns logstream WSS stream information.
586
     *
587
     * @return LogstreamResponse
588
     */
589
    public function getLogstream($environmentUuid)
590
    {
591
        return new LogstreamResponse(
592
            $this->client->request('get', "/environments/${environmentUuid}/logstream")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...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

592
            /** @scrutinizer ignore-type */ $this->client->request('get', "/environments/${environmentUuid}/logstream")
Loading history...
593
        );
594
    }
595
596
    /**
597
     * Returns a list of SSL certificates.
598
     *
599
     * @param string $environmentUuid The environment ID
600
     * @return CertificatesResponse
601
     */
602
    public function getSslCertificates($environmentUuid)
603
    {
604
        return new CertificatesResponse(
605
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...id.'/ssl/certificates') can also be of type Psr\Http\Message\StreamInterface and object; however, parameter $certificates 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

605
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
606
                'get',
607
                "/environments/${environmentUuid}/ssl/certificates"
608
            )
609
        );
610
    }
611
612
    /**
613
     * Returns a specific certificate by certificate ID.
614
     *
615
     * @param string $environmentUuid The environment ID
616
     * @param int    $certificateId
617
     * @return CertificateResponse
618
     */
619
    public function getSslCertificate($environmentUuid, $certificateId)
620
    {
621
        return new CertificateResponse(
622
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...cates/'.$certificateId) can also be of type array; however, parameter $certificate 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

622
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
623
                'get',
624
                "/environments/${environmentUuid}/ssl/certificates/${certificateId}"
625
            )
626
        );
627
    }
628
629
    /**
630
     * Install an SSL certificate.
631
     *
632
     * @param string $envUuid
633
     * @param string $label
634
     * @param string $cert
635
     * @param string $key
636
     * @param string $ca
637
     * @param int    $csr
638
     * @param bool   $legacy
639
     * @return OperationResponse
640
     */
641
    public function createSslCertificate($envUuid, $label, $cert, $key, $ca = null, $csr = null, $legacy = false)
642
    {
643
644
        $options = [
645
            'form_params' => [
646
                'label' => $label,
647
                'certificate' => $cert,
648
                'private_key' => $key,
649
                'ca_certificates' => $ca,
650
                'csr_id' => $csr,
651
                'legacy' => $legacy
652
            ],
653
        ];
654
655
        return new OperationResponse(
656
            $this->client->request('post', "/environments/${envUuid}/ssl/certificates", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ertificates', $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

656
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${envUuid}/ssl/certificates", $options)
Loading history...
657
        );
658
    }
659
660
    /**
661
     * Delete a specific certificate by ID.
662
     *
663
     * @param string $environmentUuid
664
     * @param int    $certificateId
665
     * @return OperationResponse
666
     */
667
    public function deleteSslCertificate($environmentUuid, $certificateId)
668
    {
669
        return new OperationResponse(
670
            $this->client->request('delete', "/environments/${environmentUuid}/ssl/certificates/${certificateId}")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...cates/'.$certificateId) 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

670
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/environments/${environmentUuid}/ssl/certificates/${certificateId}")
Loading history...
671
        );
672
    }
673
674
    /**
675
     * Deactivates an active SSL certificate.
676
     *
677
     * @param string $environmentUuid
678
     * @param int    $certificateId
679
     * @return OperationResponse
680
     */
681
    public function deactivateSslCertificate($environmentUuid, $certificateId)
682
    {
683
        return new OperationResponse(
684
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('....'/actions/deactivate') 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

684
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
685
                'post',
686
                "/environments/${environmentUuid}/ssl/certificate/${certificateId}/actions/deactivate"
687
            )
688
        );
689
    }
690
691
    /**
692
     * Activates an SSL certificate.
693
     *
694
     * @param string $environmentUuid
695
     * @param int    $certificateId
696
     * @return OperationResponse
697
     */
698
    public function activateSslCertificate($environmentUuid, $certificateId)
699
    {
700
        return new OperationResponse(
701
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...Id.'/actions/activate') 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->client->request(
Loading history...
702
                'post',
703
                "/environments/${environmentUuid}/ssl/certificate/${certificateId}/actions/activate"
704
            )
705
        );
706
    }
707
708
   /**
709
    * Returns a list of log forwarding destinations.
710
    *
711
    * @param string $environmentUuid The environment ID
712
    * @return LogForwardingDestinationsResponse
713
    */
714
    public function getLogDestinations($environmentUuid)
715
    {
716
        return new LogForwardingDestinationsResponse(
717
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...rwarding-destinations') can also be of type Psr\Http\Message\StreamInterface and object; however, parameter $destinations 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

717
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
718
                'get',
719
                "/environments/${environmentUuid}/log-forwarding-destinations"
720
            )
721
        );
722
    }
723
724
   /**
725
    * Returns a specific log forwarding destination.
726
    *
727
    * @param string $environmentUuid The environment ID
728
    * @param int    $destinationId
729
    * @return LogForwardingDestinationResponse
730
    */
731
    public function getLogDestination($environmentUuid, $destinationId)
732
    {
733
        return new LogForwardingDestinationResponse(
734
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...tions/'.$destinationId) can also be of type array; however, parameter $destination 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

734
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
735
                'get',
736
                "/environments/${environmentUuid}/log-forwarding-destinations/${destinationId}"
737
            )
738
        );
739
    }
740
741
   /**
742
    * Creates a log forwarding destination.
743
    *
744
    * @param string $environmentUuid
745
    * @param string $label
746
    * @param array  $sources
747
    * @param string $consumer
748
    * @param array  $credentials
749
    * @param string $address
750
    * @return OperationResponse
751
    */
752
    public function createLogDestination($environmentUuid, $label, $sources, $consumer, $credentials, $address)
753
    {
754
755
        $options = [
756
            'form_params' => [
757
                'label' => $label,
758
                'sources' => $sources,
759
                'consumer' => $consumer,
760
                'credentials' => $credentials,
761
                'address' => $address
762
            ],
763
        ];
764
765
        return new OperationResponse(
766
            $this->client->request('post', "/environments/${environmentUuid}/log-forwarding-destinations", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...estinations', $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

766
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuid}/log-forwarding-destinations", $options)
Loading history...
767
        );
768
    }
769
770
   /**
771
    * Delete a specific log forwarding destination.
772
    *
773
    * @param string $environmentUuid
774
    * @param int    $destId
775
    * @return OperationResponse
776
    */
777
    public function deleteLogDestination($environmentUuid, $destId)
778
    {
779
        return new OperationResponse(
780
            $this->client->request('delete', "/environments/${environmentUuid}/log-forwarding-destinations/${destId}")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...destinations/'.$destId) 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

780
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/environments/${environmentUuid}/log-forwarding-destinations/${destId}")
Loading history...
781
        );
782
    }
783
784
   /**
785
    * Disables a log forwarding destination.
786
    *
787
    * @param string $environmentUuid
788
    * @param int    $destId
789
    * @return OperationResponse
790
    */
791
    public function disableLogDestination($environmentUuid, $destId)
792
    {
793
        return new OperationResponse(
794
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...tId.'/actions/disable') 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

794
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
795
                'post',
796
                "/environments/${environmentUuid}/log-forwarding-destinations/${destId}/actions/disable"
797
            )
798
        );
799
    }
800
801
   /**
802
    * Disables a log forwarding destination.
803
    *
804
    * @param string $environmentUuid
805
    * @param int    $destId
806
    * @return OperationResponse
807
    */
808
    public function enableLogDestination($environmentUuid, $destId)
809
    {
810
        return new OperationResponse(
811
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...stId.'/actions/enable') 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

811
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
812
                'post',
813
                "/environments/${environmentUuid}/log-forwarding-destinations/${destId}/actions/enable"
814
            )
815
        );
816
    }
817
818
   /**
819
    * Updates a log forwarding destination.
820
    *
821
    * @param string $environmentUuid
822
    * @param int    $destId
823
    * @param string $label
824
    * @param array  $sources
825
    * @param string $consumer
826
    * @param array  $creds
827
    * @param string $address
828
    * @return OperationResponse
829
    */
830
    public function updateLogDestination($environmentUuid, $destId, $label, $sources, $consumer, $creds, $address)
831
    {
832
833
        $options = [
834
            'form_params' => [
835
                'label' => $label,
836
                'sources' => $sources,
837
                'consumer' => $consumer,
838
                'credentials' => $creds,
839
                'address' => $address
840
            ],
841
        ];
842
843
        return new OperationResponse(
844
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ns/'.$destId, $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->client->request(
Loading history...
845
                'put',
846
                "/environments/${environmentUuid}/log-forwarding-destinations/${destId}",
847
                $options
848
            )
849
        );
850
    }
851
}
852