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

Application::getApplications()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
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
    /**
23
     * Client constructor.
24
     *
25
     * @param ConnectorInterface $connector
0 ignored issues
show
Bug introduced by
The type AcquiaCloudApi\Endpoints\ConnectorInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
     */
27
    public function __construct(ClientInterface $client)
28
    {
29
        $this->client = $client;
0 ignored issues
show
Bug Best Practice introduced by
The property client does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
30
    }
31
32
    /**
33
     * Shows all applications.
34
     *
35
     * @return ApplicationsResponse
36
     */
37
    public function getApplications()
38
    {
39
        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 AcquiaCloudApi\Connector\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

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

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

75
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
76
                'put',
77
                "/applications/${applicationUuid}",
78
                $options
79
            )
80
        );
81
    }
82
83
    /**
84
     * Shows all code branches and tags in an application.
85
     *
86
     * @param string $applicationUuid
87
     * @return BranchesResponse
88
     */
89
    public function getBranches($applicationUuid)
90
    {
91
        return new BranchesResponse(
92
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...pplicationUuid.'/code') can also be of type AcquiaCloudApi\Connector\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

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

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

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

145
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/applications/${applicationUuid}/databases/${name}")
Loading history...
146
        );
147
    }
148
149
    /**
150
     * Shows all tasks in an application.
151
     *
152
     * @param string $applicationUuid
153
     * @return TasksResponse
154
     */
155
    public function getTasks($applicationUuid)
156
    {
157
        return new TasksResponse(
158
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...plicationUuid.'/tasks') can also be of type AcquiaCloudApi\Connector\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

158
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
159
                'get',
160
                "/applications/${applicationUuid}/tasks"
161
            )
162
        );
163
    }
164
165
    /**
166
     * Shows all environments in an application.
167
     *
168
     * @param string $applicationUuid
169
     * @return EnvironmentsResponse
170
     */
171
    public function getEnvironments($applicationUuid)
172
    {
173
        return new EnvironmentsResponse(
174
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...onUuid.'/environments') can also be of type AcquiaCloudApi\Connector\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

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

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