Completed
Pull Request — master (#34)
by Adam
03:27
created

Environments::getDomain()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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)
0 ignored issues
show
Unused Code introduced by
The parameter $legacy is not used and could be removed. ( Ignorable by Annotation )

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

641
    public function createSslCertificate($envUuid, $label, $cert, $key, $ca = null, $csr = null, /** @scrutinizer ignore-unused */ $legacy = false)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
642
    {
643
644
        $options = [
645
            'form_params' => [
646
                'label' => $label,
647
                'certificate' => $cert,
648
                'private_key' => $key,
649
            ],
650
        ];
651
652
        if ($ca) {
653
            $options['form_params']['ca_certificates'] = $ca;
654
        }
655
        if ($csr) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $csr of type integer|null is loosely compared to true; this is ambiguous if the integer can be 0. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
656
            $options['form_params']['csr_id'] = $csr;
657
        }
658
659
        return new OperationResponse(
660
            $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

660
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${envUuid}/ssl/certificates", $options)
Loading history...
661
        );
662
    }
663
664
    /**
665
     * Delete a specific certificate by ID.
666
     *
667
     * @param string $environmentUuid
668
     * @param int    $certificateId
669
     * @return OperationResponse
670
     */
671
    public function deleteSslCertificate($environmentUuid, $certificateId)
672
    {
673
        return new OperationResponse(
674
            $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

674
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/environments/${environmentUuid}/ssl/certificates/${certificateId}")
Loading history...
675
        );
676
    }
677
678
    /**
679
     * Deactivates an active SSL certificate.
680
     *
681
     * @param string $environmentUuid
682
     * @param int    $certificateId
683
     * @return OperationResponse
684
     */
685
    public function deactivateSslCertificate($environmentUuid, $certificateId)
686
    {
687
        return new OperationResponse(
688
            $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

688
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
689
                'post',
690
                "/environments/${environmentUuid}/ssl/certificate/${certificateId}/actions/deactivate"
691
            )
692
        );
693
    }
694
695
    /**
696
     * Activates an SSL certificate.
697
     *
698
     * @param string $environmentUuid
699
     * @param int    $certificateId
700
     * @return OperationResponse
701
     */
702
    public function activateSslCertificate($environmentUuid, $certificateId)
703
    {
704
        return new OperationResponse(
705
            $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

705
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
706
                'post',
707
                "/environments/${environmentUuid}/ssl/certificate/${certificateId}/actions/activate"
708
            )
709
        );
710
    }
711
712
   /**
713
    * Returns a list of log forwarding destinations.
714
    *
715
    * @param string $environmentUuid The environment ID
716
    * @return LogForwardingDestinationsResponse
717
    */
718
    public function getLogDestinations($environmentUuid)
719
    {
720
        return new LogForwardingDestinationsResponse(
721
            $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

721
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
722
                'get',
723
                "/environments/${environmentUuid}/log-forwarding-destinations"
724
            )
725
        );
726
    }
727
728
   /**
729
    * Returns a specific log forwarding destination.
730
    *
731
    * @param string $environmentUuid The environment ID
732
    * @param int    $destinationId
733
    * @return LogForwardingDestinationResponse
734
    */
735
    public function getLogDestination($environmentUuid, $destinationId)
736
    {
737
        return new LogForwardingDestinationResponse(
738
            $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

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

770
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuid}/log-forwarding-destinations", $options)
Loading history...
771
        );
772
    }
773
774
   /**
775
    * Delete a specific log forwarding destination.
776
    *
777
    * @param string $environmentUuid
778
    * @param int    $destId
779
    * @return OperationResponse
780
    */
781
    public function deleteLogDestination($environmentUuid, $destId)
782
    {
783
        return new OperationResponse(
784
            $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

784
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/environments/${environmentUuid}/log-forwarding-destinations/${destId}")
Loading history...
785
        );
786
    }
787
788
   /**
789
    * Disables a log forwarding destination.
790
    *
791
    * @param string $environmentUuid
792
    * @param int    $destId
793
    * @return OperationResponse
794
    */
795
    public function disableLogDestination($environmentUuid, $destId)
796
    {
797
        return new OperationResponse(
798
            $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

798
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
799
                'post',
800
                "/environments/${environmentUuid}/log-forwarding-destinations/${destId}/actions/disable"
801
            )
802
        );
803
    }
804
805
   /**
806
    * Disables a log forwarding destination.
807
    *
808
    * @param string $environmentUuid
809
    * @param int    $destId
810
    * @return OperationResponse
811
    */
812
    public function enableLogDestination($environmentUuid, $destId)
813
    {
814
        return new OperationResponse(
815
            $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

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

848
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
849
                'put',
850
                "/environments/${environmentUuid}/log-forwarding-destinations/${destId}",
851
                $options
852
            )
853
        );
854
    }
855
}
856