Passed
Push — master ( 23fcc1...e399e4 )
by Adam
04:08 queued 11s
created

Environments::enableProductionMode()   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 1
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\OperationResponse;
9
10
/**
11
 * Class Environments
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class Environments extends CloudApiBase implements CloudApiInterface
15
{
16
17
    /**
18
     * Copies files from an environment to another environment.
19
     *
20
     * @param string $environmentUuidFrom
21
     * @param string $environmentUuidTo
22
     * @return OperationResponse
23
     */
24
    public function copyFiles($environmentUuidFrom, $environmentUuidTo)
25
    {
26
        $options = [
27
            'form_params' => [
28
                'source' => $environmentUuidFrom,
29
            ],
30
        ];
31
32
        return new OperationResponse(
33
            $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

33
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuidTo}/files", $options)
Loading history...
34
        );
35
    }
36
37
    /**
38
     * Gets information about an environment.
39
     *
40
     * @param string $environmentUuid
41
     * @return EnvironmentResponse
42
     */
43
    public function get($environmentUuid)
44
    {
45
        return new EnvironmentResponse(
46
            $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

46
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
47
                'get',
48
                "/environments/${environmentUuid}"
49
            )
50
        );
51
    }
52
53
    /**
54
     * Shows all environments in an application.
55
     *
56
     * @param string $applicationUuid
57
     * @return EnvironmentsResponse
58
     */
59
    public function getAll($applicationUuid)
60
    {
61
        return new EnvironmentsResponse(
62
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...onUuid.'/environments') can also be of type 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

62
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
63
                'get',
64
                "/applications/${applicationUuid}/environments"
65
            )
66
        );
67
    }
68
69
    /**
70
     * Modifies configuration settings for an environment.
71
     *
72
     * @param string $environmentUuid
73
     * @param array $config
74
     * @return OperationResponse
75
     */
76
    public function update($environmentUuid, array $config)
77
    {
78
79
        $options = [
80
            'form_params' => $config,
81
        ];
82
83
        return new OperationResponse(
84
            $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

84
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
85
                'put',
86
                "/environments/${environmentUuid}",
87
                $options
88
            )
89
        );
90
    }
91
92
    /**
93
     * Renames an environment.
94
     *
95
     * @param string $environmentUuid
96
     * @param string $label
97
     * @return OperationResponse
98
     */
99
    public function rename($environmentUuid, $label)
100
    {
101
102
        $options = [
103
            'form_params' => [
104
                'label' => $label,
105
            ],
106
        ];
107
108
        return new OperationResponse(
109
            $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

109
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
110
                'post',
111
                "/environments/${environmentUuid}/actions/change-label",
112
                $options
113
            )
114
        );
115
    }
116
117
    /**
118
     * Enable livedev mode for an environment.
119
     *
120
     * @param string $environmentUuid
121
     * @return OperationResponse
122
     */
123
    public function enableLiveDev($environmentUuid)
124
    {
125
        return new OperationResponse(
126
            $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

126
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuid}/livedev/actions/enable")
Loading history...
127
        );
128
    }
129
130
    /**
131
     * Disable livedev mode for an environment.
132
     *
133
     * @param string $environmentUuid
134
     * @return OperationResponse
135
     */
136
    public function disableLiveDev($environmentUuid)
137
    {
138
139
        $options = [
140
            'form_params' => [
141
                'discard' => 1,
142
            ],
143
        ];
144
145
        return new OperationResponse(
146
            $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

146
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
147
                'post',
148
                "/environments/${environmentUuid}/livedev/actions/disable",
149
                $options
150
            )
151
        );
152
    }
153
154
    /**
155
     * Enable production mode for an environment.
156
     *
157
     * @param string $environmentUuid
158
     * @return OperationResponse
159
     */
160
    public function enableProductionMode($environmentUuid)
161
    {
162
        return new OperationResponse(
163
            $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

163
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
164
                'post',
165
                "/environments/${environmentUuid}/production-mode/actions/enable"
166
            )
167
        );
168
    }
169
170
    /**
171
     * Disable production mode for an environment.
172
     *
173
     * @param string $environmentUuid
174
     * @return OperationResponse
175
     */
176
    public function disableProductionMode($environmentUuid)
177
    {
178
        return new OperationResponse(
179
            $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

179
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
180
                'post',
181
                "/environments/${environmentUuid}/production-mode/actions/disable"
182
            )
183
        );
184
    }
185
186
    /**
187
     * Add a new continuous delivery environment to an application.
188
     *
189
     * @param string $applicationUuid
190
     * @param string $label
191
     * @param string $branch
192
     * @param array  $databases
193
     * @return OperationResponse
194
     */
195
    public function create($applicationUuid, $label, $branch, array $databases)
196
    {
197
        $options = [
198
            'form_params' => [
199
                'label' => $label,
200
                'branch' => $branch,
201
                'databases' => $databases,
202
            ],
203
        ];
204
205
        return new OperationResponse(
206
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...nvironments', $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

206
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
207
                'post',
208
                "/applications/${applicationUuid}/environments",
209
                $options
210
            )
211
        );
212
    }
213
214
    /**
215
     * Deletes a CD environment.
216
     *
217
     * @param string $environmentUuid
218
     * @return OperationResponse
219
     */
220
    public function delete($environmentUuid)
221
    {
222
        return new OperationResponse(
223
            $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 $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

223
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
224
                'delete',
225
                "/environments/${environmentUuid}"
226
            )
227
        );
228
    }
229
}
230