Completed
Pull Request — master (#34)
by Adam
02:26
created

Application::deleteDatabase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 1
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\ApplicationResponse;
7
use AcquiaCloudApi\Response\ApplicationsResponse;
8
use AcquiaCloudApi\Response\DatabasesResponse;
9
use AcquiaCloudApi\Response\BranchesResponse;
10
use AcquiaCloudApi\Response\EnvironmentsResponse;
11
use AcquiaCloudApi\Response\InsightsResponse;
12
use AcquiaCloudApi\Response\TasksResponse;
13
use AcquiaCloudApi\Response\OperationResponse;
14
15
/**
16
 * Class Client
17
 * @package AcquiaCloudApi\CloudApi
18
 */
19
class Application implements CloudApi
20
{
21
22
    /** @var ClientInterface The API client. */
23
    protected $client;
24
25
    /**
26
     * Client constructor.
27
     *
28
     * @param ClientInterface $client
29
     */
30
    public function __construct(ClientInterface $client)
31
    {
32
        $this->client = $client;
33
    }
34
35
    /**
36
     * Shows all applications.
37
     *
38
     * @return ApplicationsResponse
39
     */
40
    public function getApplications()
41
    {
42
        return new ApplicationsResponse($this->client->request('get', '/applications'));
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('get', '/applications') can also be of type Psr\Http\Message\StreamInterface and object; however, parameter $applications of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

42
        return new ApplicationsResponse(/** @scrutinizer ignore-type */ $this->client->request('get', '/applications'));
Loading history...
43
    }
44
45
    /**
46
     * Shows information about an application.
47
     *
48
     * @param string $applicationUuid
49
     * @return ApplicationResponse
50
     */
51
    public function getApplication($applicationUuid)
52
    {
53
        return new ApplicationResponse(
54
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ons/'.$applicationUuid) can also be of type array; however, parameter $application of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept object, maybe add an additional type check? ( Ignorable by Annotation )

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

54
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
55
                'get',
56
                "/applications/${applicationUuid}"
57
            )
58
        );
59
    }
60
61
    /**
62
     * Renames an application.
63
     *
64
     * @param string $applicationUuid
65
     * @param string $name
66
     * @return OperationResponse
67
     */
68
    public function renameApplication($applicationUuid, $name)
69
    {
70
71
        $options = [
72
            'form_params' => [
73
                'name' => $name,
74
            ],
75
        ];
76
77
        return new OperationResponse(
78
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...licationUuid, $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(
Loading history...
79
                'put',
80
                "/applications/${applicationUuid}",
81
                $options
82
            )
83
        );
84
    }
85
86
    /**
87
     * Shows all code branches and tags in an application.
88
     *
89
     * @param string $applicationUuid
90
     * @return BranchesResponse
91
     */
92
    public function getBranches($applicationUuid)
93
    {
94
        return new BranchesResponse(
95
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...pplicationUuid.'/code') can also be of type Psr\Http\Message\StreamInterface and object; however, parameter $branches of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

95
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
96
                'get',
97
                "/applications/${applicationUuid}/code"
98
            )
99
        );
100
    }
101
102
    /**
103
     * Shows all databases in an application.
104
     *
105
     * @param string $applicationUuid
106
     * @return DatabasesResponse
107
     */
108
    public function getDatabases($applicationUuid)
109
    {
110
        return new DatabasesResponse(
111
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ationUuid.'/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

111
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
112
                'get',
113
                "/applications/${applicationUuid}/databases"
114
            )
115
        );
116
    }
117
118
    /**
119
     * Create a new database.
120
     *
121
     * @param string $applicationUuid
122
     * @param string $name
123
     * @return OperationResponse
124
     */
125
    public function createDatabase($applicationUuid, $name)
126
    {
127
        $options = [
128
            'form_params' => [
129
                'name' => $name,
130
            ],
131
        ];
132
133
        return new OperationResponse(
134
            $this->client->request('post', "/applications/${applicationUuid}/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

134
            /** @scrutinizer ignore-type */ $this->client->request('post', "/applications/${applicationUuid}/databases", $options)
Loading history...
135
        );
136
    }
137
138
    /**
139
     * Delete a database.
140
     *
141
     * @param string $applicationUuid
142
     * @param string $name
143
     * @return OperationResponse
144
     */
145
    public function deleteDatabase($applicationUuid, $name)
146
    {
147
        return new OperationResponse(
148
            $this->client->request('delete', "/applications/${applicationUuid}/databases/${name}")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...id.'/databases/'.$name) 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

148
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/applications/${applicationUuid}/databases/${name}")
Loading history...
149
        );
150
    }
151
152
    /**
153
     * Shows all tasks in an application.
154
     *
155
     * @param string $applicationUuid
156
     * @return TasksResponse
157
     */
158
    public function getTasks($applicationUuid)
159
    {
160
        return new TasksResponse(
161
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...plicationUuid.'/tasks') can also be of type Psr\Http\Message\StreamInterface and object; however, parameter $tasks of AcquiaCloudApi\Response\...Response::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

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

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

177
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
178
                'get',
179
                "/applications/${applicationUuid}/environments"
180
            )
181
        );
182
    }
183
184
    /**
185
     * Show insights data from an application.
186
     *
187
     * @param string $applicationUuid
188
     * @return InsightsResponse
189
     */
190
    public function getInsights($applicationUuid)
191
    {
192
        return new InsightsResponse(
193
            $this->client->request('get', "/applications/${applicationUuid}/insight")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...icationUuid.'/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

193
            /** @scrutinizer ignore-type */ $this->client->request('get', "/applications/${applicationUuid}/insight")
Loading history...
194
        );
195
    }
196
}
197