Completed
Pull Request — master (#34)
by Adam
03:21
created

Servers::__construct()   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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
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 Client
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class Servers 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
     * Gets information about a single server.
32
     *
33
     * @param string $environmentUuid
34
     * @param string $serverId
35
     * @return ServerResponse
36
     */
37
    public function get($environmentUuid, $serverId)
38
    {
39
        return new ServerResponse(
40
            $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

40
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
41
                'get',
42
                "/environments/${environmentUuid}/servers/${serverId}"
43
            )
44
        );
45
    }
46
47
    /**
48
     * Modifies configuration settings for a server.
49
     *
50
     * @param string $environmentUuid
51
     * @param string $serverId
52
     * @param array  $config
53
     * @return OperationResponse
54
     */
55
    public function update($environmentUuid, $serverId, array $config)
56
    {
57
58
        return new OperationResponse(
59
            $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

59
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
60
                'put',
61
                "/environments/${environmentUuid}/servers/${serverId}",
62
                $config
63
            )
64
        );
65
    }
66
67
    /**
68
     * Show all servers associated with an environment.
69
     *
70
     * @param string $environmentUuid
71
     * @return ServersResponse
72
     */
73
    public function getAll($environmentUuid)
74
    {
75
        return new ServersResponse(
76
            $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

76
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
77
                'get',
78
                "/environments/${environmentUuid}/servers"
79
            )
80
        );
81
    }
82
}
83