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

Servers::getAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
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\OperationResponse;
7
use AcquiaCloudApi\Response\ServersResponse;
8
use AcquiaCloudApi\Response\ServerResponse;
9
10
/**
11
 * Class Servers
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class Servers extends CloudApiBase implements CloudApiInterface
15
{
16
17
    /**
18
     * Gets information about a single server.
19
     *
20
     * @param string $environmentUuid
21
     * @param string $serverId
22
     * @return ServerResponse
23
     */
24
    public function get($environmentUuid, $serverId)
25
    {
26
        return new ServerResponse(
27
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('....'/servers/'.$serverId) can also be of type array; however, parameter $server 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

27
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
28
                'get',
29
                "/environments/${environmentUuid}/servers/${serverId}"
30
            )
31
        );
32
    }
33
34
    /**
35
     * Modifies configuration settings for a server.
36
     *
37
     * @param string $environmentUuid
38
     * @param string $serverId
39
     * @param array  $config
40
     * @return OperationResponse
41
     */
42
    public function update($environmentUuid, $serverId, array $config)
43
    {
44
45
        return new OperationResponse(
46
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...s/'.$serverId, $config) 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(
Loading history...
47
                'put',
48
                "/environments/${environmentUuid}/servers/${serverId}",
49
                $config
50
            )
51
        );
52
    }
53
54
    /**
55
     * Show all servers associated with an environment.
56
     *
57
     * @param string $environmentUuid
58
     * @return ServersResponse
59
     */
60
    public function getAll($environmentUuid)
61
    {
62
        return new ServersResponse(
63
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ronmentUuid.'/servers') can also be of type object; however, parameter $servers 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

63
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
64
                'get',
65
                "/environments/${environmentUuid}/servers"
66
            )
67
        );
68
    }
69
}
70