Passed
Pull Request — master (#34)
by Adam
03:39
created

DatabaseBackups::getAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
rs 10
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Connector\ClientInterface;
6
use AcquiaCloudApi\Response\BackupsResponse;
7
use AcquiaCloudApi\Response\BackupResponse;
8
use AcquiaCloudApi\Response\OperationResponse;
9
10
/**
11
 * Class DatabaseBackups
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class DatabaseBackups extends CloudApiBase implements CloudApiInterface
15
{
16
17
    /**
18
     * Backup a database.
19
     *
20
     * @param string $environmentUuid
21
     * @param string $dbName
22
     * @return OperationResponse
23
     */
24
    public function create($environmentUuid, $dbName)
25
    {
26
        return new OperationResponse(
27
            $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

27
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
28
                'post',
29
                "/environments/${environmentUuid}/databases/${dbName}/backups"
30
            )
31
        );
32
    }
33
34
    /**
35
     * Shows all database backups in an environment.
36
     *
37
     * @param string $environmentUuid
38
     * @param string $dbName
39
     * @return BackupsResponse
40
     */
41
    public function getAll($environmentUuid, $dbName)
42
    {
43
        return new BackupsResponse(
44
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...s/'.$dbName.'/backups') can also be of type 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

44
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
45
                'get',
46
                "/environments/${environmentUuid}/databases/${dbName}/backups"
47
            )
48
        );
49
    }
50
51
    /**
52
     * Gets information about a database backup.
53
     *
54
     * @param string $environmentUuid
55
     * @param string $dbName
56
     * @param int    $backupId
57
     * @return BackupResponse
58
     */
59
    public function get($environmentUuid, $dbName, $backupId)
60
    {
61
        return new BackupResponse(
62
            $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

62
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
63
                'get',
64
                "/environments/${environmentUuid}/databases/${dbName}/backups/${backupId}"
65
            )
66
        );
67
    }
68
69
    /**
70
     * Restores a database backup to a database in an environment.
71
     *
72
     * @param string $environmentUuid
73
     * @param string $dbName
74
     * @param int    $backupId
75
     * @return OperationResponse
76
     */
77
    public function restore($environmentUuid, $dbName, $backupId)
78
    {
79
        return new OperationResponse(
80
            $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

80
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
81
                'post',
82
                "/environments/${environmentUuid}/databases/${dbName}/backups/${backupId}/actions/restore"
83
            )
84
        );
85
    }
86
}
87