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

Domains::status()   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
nc 1
nop 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Connector\ClientInterface;
6
use AcquiaCloudApi\Response\DomainsResponse;
7
use AcquiaCloudApi\Response\DomainResponse;
8
use AcquiaCloudApi\Response\OperationResponse;
9
use AcquiaCloudApi\Response\MetricsResponse;
10
11
/**
12
 * Class Domains
13
 * @package AcquiaCloudApi\CloudApi
14
 */
15
class Domains extends CloudApiBase implements CloudApiInterface
16
{
17
18
    /**
19
     * Shows all domains on an environment.
20
     *
21
     * @param string $environmentUuid
22
     * @return DomainsResponse
23
     */
24
    public function getAll($environmentUuid)
25
    {
26
        return new DomainsResponse(
27
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ronmentUuid.'/domains') can also be of type object; however, parameter $domains 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

27
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
28
                'get',
29
                "/environments/${environmentUuid}/domains"
30
            )
31
        );
32
    }
33
34
    /**
35
     * Return details about a domain.
36
     *
37
     * @param string $environmentUuid
38
     * @param string $domain
39
     * @return DomainResponse
40
     */
41
    public function get($environmentUuid, $domain)
42
    {
43
        return new DomainResponse(
44
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...id.'/domains/'.$domain) can also be of type array; however, parameter $domain 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

44
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
45
                'get',
46
                "/environments/${environmentUuid}/domains/${domain}"
47
            )
48
        );
49
    }
50
51
    /**
52
     * Adds a domain to an environment.
53
     *
54
     * @param string $environmentUuid
55
     * @param string $hostname
56
     * @return OperationResponse
57
     */
58
    public function create($environmentUuid, $hostname)
59
    {
60
61
        $options = [
62
            'form_params' => [
63
                'hostname' => $hostname,
64
            ],
65
        ];
66
67
        return new OperationResponse(
68
            $this->client->request('post', "/environments/${environmentUuid}/domains", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...d.'/domains', $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

68
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuid}/domains", $options)
Loading history...
69
        );
70
    }
71
72
    /**
73
     * Deletes a domain from an environment.
74
     *
75
     * @param string $environmentUuid
76
     * @param string $domain
77
     * @return OperationResponse
78
     */
79
    public function delete($environmentUuid, $domain)
80
    {
81
        return new OperationResponse(
82
            $this->client->request('delete', "/environments/${environmentUuid}/domains/${domain}")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...id.'/domains/'.$domain) 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

82
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/environments/${environmentUuid}/domains/${domain}")
Loading history...
83
        );
84
    }
85
86
    /**
87
     * Purges varnish for selected domains in an environment.
88
     *
89
     * @param string $environmentUuid
90
     * @param array  $domains
91
     * @return OperationResponse
92
     */
93
    public function purge($environmentUuid, array $domains)
94
    {
95
96
        $options = [
97
            'form_params' => [
98
                'domains' => $domains,
99
            ],
100
        ];
101
102
        return new OperationResponse(
103
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ear-varnish', $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

103
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
104
                'post',
105
                "/environments/${environmentUuid}/domains/actions/clear-varnish",
106
                $options
107
            )
108
        );
109
    }
110
111
    /**
112
     * Retrieves the scan data for a domain name that is part of this environment.
113
     *
114
     * @param string $environmentUuid
115
     * @param string $domain
116
     * @return MetricsResponse
117
     */
118
    public function metrics($environmentUuid, $domain)
119
    {
120
        return new MetricsResponse(
121
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...main.'/metrics/uptime') can also be of type object; however, parameter $metrics 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

121
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
122
                'get',
123
                "/environments/${environmentUuid}/domains/${domain}/metrics/uptime"
124
            )
125
        );
126
    }
127
128
    /**
129
     * Returns details about the domain.
130
     *
131
     * @param string $environmentUuid
132
     * @param string $domain
133
     * @return DomainResponse
134
     */
135
    public function status($environmentUuid, $domain)
136
    {
137
        return new DomainResponse(
138
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ns/'.$domain.'/status') can also be of type array; however, parameter $domain 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

138
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
139
                'get',
140
                "/environments/${environmentUuid}/domains/${domain}/status"
141
            )
142
        );
143
    }
144
}
145