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

Environments::getAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
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 Client
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class Environments implements CloudApi
15
{
16
17
    /** @var ClientInterface The API client. */
18
    protected $client;
19
20
    /**
21
     * Client constructor.
22
     *
23
     * @param ClientInterface $client
24
     */
25
    public function __construct(ClientInterface $client)
26
    {
27
        $this->client = $client;
28
    }
29
30
    /**
31
     * Copies files from an environment to another environment.
32
     *
33
     * @param string $environmentUuidFrom
34
     * @param string $environmentUuidTo
35
     * @return OperationResponse
36
     */
37
    public function copyFiles($environmentUuidFrom, $environmentUuidTo)
38
    {
39
        $options = [
40
            'form_params' => [
41
                'source' => $environmentUuidFrom,
42
            ],
43
        ];
44
45
        return new OperationResponse(
46
            $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

46
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuidTo}/files", $options)
Loading history...
47
        );
48
    }
49
50
    /**
51
     * Gets information about an environment.
52
     *
53
     * @param string $environmentUuid
54
     * @return EnvironmentResponse
55
     */
56
    public function get($environmentUuid)
57
    {
58
        return new EnvironmentResponse(
59
            $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

59
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
60
                'get',
61
                "/environments/${environmentUuid}"
62
            )
63
        );
64
    }
65
66
    /**
67
     * Shows all environments in an application.
68
     *
69
     * @param string $applicationUuid
70
     * @return EnvironmentsResponse
71
     */
72
    public function getAll($applicationUuid)
73
    {
74
        return new EnvironmentsResponse(
75
            $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

75
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
76
                'get',
77
                "/applications/${applicationUuid}/environments"
78
            )
79
        );
80
    }
81
82
    /**
83
     * Modifies configuration settings for an environment.
84
     *
85
     * @param string $environmentUuid
86
     * @param array $config
87
     * @return OperationResponse
88
     */
89
    public function update($environmentUuid, array $config)
90
    {
91
92
        $options = [
93
            'form_params' => $config,
94
        ];
95
96
        return new OperationResponse(
97
            $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

97
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
98
                'put',
99
                "/environments/${environmentUuid}",
100
                $options
101
            )
102
        );
103
    }
104
105
    /**
106
     * Renames an environment.
107
     *
108
     * @param string $environmentUuid
109
     * @param string $label
110
     * @return OperationResponse
111
     */
112
    public function rename($environmentUuid, $label)
113
    {
114
115
        $options = [
116
            'form_params' => [
117
                'label' => $label,
118
            ],
119
        ];
120
121
        return new OperationResponse(
122
            $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

122
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
123
                'post',
124
                "/environments/${environmentUuid}/actions/change-label",
125
                $options
126
            )
127
        );
128
    }
129
130
    /**
131
     * Enable livedev mode for an environment.
132
     *
133
     * @param string $environmentUuid
134
     * @return OperationResponse
135
     */
136
    public function enableLiveDev($environmentUuid)
137
    {
138
        return new OperationResponse(
139
            $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

139
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuid}/livedev/actions/enable")
Loading history...
140
        );
141
    }
142
143
    /**
144
     * Disable livedev mode for an environment.
145
     *
146
     * @param string $environmentUuid
147
     * @return OperationResponse
148
     */
149
    public function disableLiveDev($environmentUuid)
150
    {
151
152
        $options = [
153
            'form_params' => [
154
                'discard' => 1,
155
            ],
156
        ];
157
158
        return new OperationResponse(
159
            $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

159
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
160
                'post',
161
                "/environments/${environmentUuid}/livedev/actions/disable",
162
                $options
163
            )
164
        );
165
    }
166
167
    /**
168
     * Enable production mode for an environment.
169
     *
170
     * @param string $environmentUuid
171
     * @return OperationResponse
172
     */
173
    public function enableProductionMode($environmentUuid)
174
    {
175
        return new OperationResponse(
176
            $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

176
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
177
                'post',
178
                "/environments/${environmentUuid}/production-mode/actions/enable"
179
            )
180
        );
181
    }
182
183
    /**
184
     * Disable production mode for an environment.
185
     *
186
     * @param string $environmentUuid
187
     * @return OperationResponse
188
     */
189
    public function disableProductionMode($environmentUuid)
190
    {
191
        return new OperationResponse(
192
            $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

192
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
193
                'post',
194
                "/environments/${environmentUuid}/production-mode/actions/disable"
195
            )
196
        );
197
    }
198
}
199