Passed
Push — master ( 23fcc1...e399e4 )
by Adam
04:08 queued 11s
created

SslCertificates   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 111
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 29
dl 0
loc 111
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 4 1
A getAll() 0 6 1
A get() 0 6 1
A enable() 0 6 1
A create() 0 16 1
A disable() 0 6 1
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Connector\ClientInterface;
6
use AcquiaCloudApi\Response\SslCertificatesResponse;
7
use AcquiaCloudApi\Response\SslCertificateResponse;
8
use AcquiaCloudApi\Response\OperationResponse;
9
10
/**
11
 * Class SslCertificates
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class SslCertificates extends CloudApiBase implements CloudApiInterface
15
{
16
17
    /**
18
     * Returns a list of SSL certificates.
19
     *
20
     * @param string $environmentUuid The environment ID
21
     * @return SslCertificatesResponse
22
     */
23
    public function getAll($environmentUuid)
24
    {
25
        return new SslCertificatesResponse(
26
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...id.'/ssl/certificates') can also be of type object; however, parameter $certificates 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

26
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
27
                'get',
28
                "/environments/${environmentUuid}/ssl/certificates"
29
            )
30
        );
31
    }
32
33
    /**
34
     * Returns a specific certificate by certificate ID.
35
     *
36
     * @param string $environmentUuid The environment ID
37
     * @param int    $certificateId
38
     * @return SslCertificateResponse
39
     */
40
    public function get($environmentUuid, $certificateId)
41
    {
42
        return new SslCertificateResponse(
43
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...cates/'.$certificateId) can also be of type array; however, parameter $certificate 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

43
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
44
                'get',
45
                "/environments/${environmentUuid}/ssl/certificates/${certificateId}"
46
            )
47
        );
48
    }
49
50
    /**
51
     * Install an SSL certificate.
52
     *
53
     * @param string $envUuid
54
     * @param string $label
55
     * @param string $cert
56
     * @param string $key
57
     * @param string $ca
58
     * @param int    $csr
59
     * @param bool   $legacy
60
     * @return OperationResponse
61
     */
62
    public function create($envUuid, $label, $cert, $key, $ca = null, $csr = null, $legacy = false)
63
    {
64
65
        $options = [
66
            'form_params' => [
67
                'label' => $label,
68
                'certificate' => $cert,
69
                'private_key' => $key,
70
                'ca_certificates' => $ca,
71
                'csr_id' => $csr,
72
                'legacy' => $legacy
73
            ],
74
        ];
75
76
        return new OperationResponse(
77
            $this->client->request('post', "/environments/${envUuid}/ssl/certificates", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ertificates', $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

77
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${envUuid}/ssl/certificates", $options)
Loading history...
78
        );
79
    }
80
81
    /**
82
     * Delete a specific certificate by ID.
83
     *
84
     * @param string $environmentUuid
85
     * @param int    $certificateId
86
     * @return OperationResponse
87
     */
88
    public function delete($environmentUuid, $certificateId)
89
    {
90
        return new OperationResponse(
91
            $this->client->request('delete', "/environments/${environmentUuid}/ssl/certificates/${certificateId}")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...cates/'.$certificateId) 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

91
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/environments/${environmentUuid}/ssl/certificates/${certificateId}")
Loading history...
92
        );
93
    }
94
95
    /**
96
     * Deactivates an active SSL certificate.
97
     *
98
     * @param string $environmentUuid
99
     * @param int    $certificateId
100
     * @return OperationResponse
101
     */
102
    public function disable($environmentUuid, $certificateId)
103
    {
104
        return new OperationResponse(
105
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('....'/actions/deactivate') 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

105
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
106
                'post',
107
                "/environments/${environmentUuid}/ssl/certificate/${certificateId}/actions/deactivate"
108
            )
109
        );
110
    }
111
112
    /**
113
     * Activates an SSL certificate.
114
     *
115
     * @param string $environmentUuid
116
     * @param int    $certificateId
117
     * @return OperationResponse
118
     */
119
    public function enable($environmentUuid, $certificateId)
120
    {
121
        return new OperationResponse(
122
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...Id.'/actions/activate') 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}/ssl/certificate/${certificateId}/actions/activate"
125
            )
126
        );
127
    }
128
}
129