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

Servers   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 63
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 8 1
A get() 0 6 1
A getAll() 0 6 1
A __construct() 0 3 1
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
     * @return ServerResponse
35
     */
36
    public function get($environmentUuid, $serverId)
37
    {
38
        return new ServerResponse(
39
            $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

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

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

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