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

Applications   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 191
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 12
eloc 45
c 0
b 0
f 0
dl 0
loc 191
rs 10

12 Methods

Rating   Name   Duplication   Size   Complexity  
A getBranches() 0 6 1
A createDatabase() 0 10 1
A deleteDatabase() 0 4 1
A getTasks() 0 6 1
A __construct() 0 3 1
A getEnvironments() 0 6 1
A getApplications() 0 3 1
A getNotifications() 0 6 1
A getDatabases() 0 6 1
A getInsights() 0 4 1
A renameApplication() 0 14 1
A getApplication() 0 6 1
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
use AcquiaCloudApi\Response\NotificationsResponse;
15
16
/**
17
 * Class Client
18
 * @package AcquiaCloudApi\CloudApi
19
 */
20
class Applications implements CloudApi
21
{
22
23
    /** @var ClientInterface The API client. */
24
    protected $client;
25
26
    /**
27
     * Client constructor.
28
     *
29
     * @param ClientInterface $client
30
     */
31
    public function __construct(ClientInterface $client)
32
    {
33
        $this->client = $client;
34
    }
35
36
    /**
37
     * Shows all applications.
38
     *
39
     * @return ApplicationsResponse
40
     */
41
    public function getApplications()
42
    {
43
        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

43
        return new ApplicationsResponse(/** @scrutinizer ignore-type */ $this->client->request('get', '/applications'));
Loading history...
44
    }
45
46
    /**
47
     * Shows information about an application.
48
     *
49
     * @param string $applicationUuid
50
     * @return ApplicationResponse
51
     */
52
    public function getApplication($applicationUuid)
53
    {
54
        return new ApplicationResponse(
55
            $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

55
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
56
                'get',
57
                "/applications/${applicationUuid}"
58
            )
59
        );
60
    }
61
62
    /**
63
     * Renames an application.
64
     *
65
     * @param string $applicationUuid
66
     * @param string $name
67
     * @return OperationResponse
68
     */
69
    public function renameApplication($applicationUuid, $name)
70
    {
71
72
        $options = [
73
            'form_params' => [
74
                'name' => $name,
75
            ],
76
        ];
77
78
        return new OperationResponse(
79
            $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

79
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
80
                'put',
81
                "/applications/${applicationUuid}",
82
                $options
83
            )
84
        );
85
    }
86
87
    /**
88
     * Shows all code branches and tags in an application.
89
     *
90
     * @param string $applicationUuid
91
     * @return BranchesResponse
92
     */
93
    public function getBranches($applicationUuid)
94
    {
95
        return new BranchesResponse(
96
            $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

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

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

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

149
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/applications/${applicationUuid}/databases/${name}")
Loading history...
150
        );
151
    }
152
153
    /**
154
     * Shows all tasks in an application.
155
     *
156
     * @param string $applicationUuid
157
     * @return TasksResponse
158
     */
159
    public function getTasks($applicationUuid)
160
    {
161
        return new TasksResponse(
162
            $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

162
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
163
                'get',
164
                "/applications/${applicationUuid}/tasks"
165
            )
166
        );
167
    }
168
169
    /**
170
     * Shows all environments in an application.
171
     *
172
     * @param string $applicationUuid
173
     * @return EnvironmentsResponse
174
     */
175
    public function getEnvironments($applicationUuid)
176
    {
177
        return new EnvironmentsResponse(
178
            $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

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

194
            /** @scrutinizer ignore-type */ $this->client->request('get', "/applications/${applicationUuid}/insight")
Loading history...
195
        );
196
    }
197
198
    /**
199
     * Returns a list of notifications.
200
     *
201
     * @param string $applicationUuid
202
     *
203
     * @return NotificationsResponse
204
     */
205
    public function getNotifications($applicationUuid)
206
    {
207
        return new NotificationsResponse(
208
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...nUuid.'/notifications') can also be of type Psr\Http\Message\StreamInterface and object; however, parameter $notifications 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

208
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
209
                'get',
210
                "/applications/${applicationUuid}/notifications"
211
            )
212
        );
213
    }
214
}
215