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

LogForwardingDestinations::enable()   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 2
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\LogForwardingDestinationsResponse;
8
use AcquiaCloudApi\Response\LogForwardingDestinationResponse;
9
10
/**
11
 * Class Client
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class LogForwardingDestinations 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
    * Returns a list of log forwarding destinations.
32
    *
33
    * @param string $environmentUuid The environment ID
34
    * @return LogForwardingDestinationsResponse
35
    */
36
    public function getAll($environmentUuid)
37
    {
38
        return new LogForwardingDestinationsResponse(
39
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...rwarding-destinations') can also be of type Psr\Http\Message\StreamInterface and object; however, parameter $destinations 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

39
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
40
                'get',
41
                "/environments/${environmentUuid}/log-forwarding-destinations"
42
            )
43
        );
44
    }
45
46
   /**
47
    * Returns a specific log forwarding destination.
48
    *
49
    * @param string $environmentUuid The environment ID
50
    * @param int    $destinationId
51
    * @return LogForwardingDestinationResponse
52
    */
53
    public function get($environmentUuid, $destinationId)
54
    {
55
        return new LogForwardingDestinationResponse(
56
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...tions/'.$destinationId) can also be of type array; however, parameter $destination 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

56
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
57
                'get',
58
                "/environments/${environmentUuid}/log-forwarding-destinations/${destinationId}"
59
            )
60
        );
61
    }
62
63
   /**
64
    * Creates a log forwarding destination.
65
    *
66
    * @param string $environmentUuid
67
    * @param string $label
68
    * @param array  $sources
69
    * @param string $consumer
70
    * @param array  $credentials
71
    * @param string $address
72
    * @return OperationResponse
73
    */
74
    public function create($environmentUuid, $label, $sources, $consumer, $credentials, $address)
75
    {
76
77
        $options = [
78
            'form_params' => [
79
                'label' => $label,
80
                'sources' => $sources,
81
                'consumer' => $consumer,
82
                'credentials' => $credentials,
83
                'address' => $address
84
            ],
85
        ];
86
87
        return new OperationResponse(
88
            $this->client->request('post', "/environments/${environmentUuid}/log-forwarding-destinations", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...estinations', $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

88
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuid}/log-forwarding-destinations", $options)
Loading history...
89
        );
90
    }
91
92
   /**
93
    * Delete a specific log forwarding destination.
94
    *
95
    * @param string $environmentUuid
96
    * @param int    $destId
97
    * @return OperationResponse
98
    */
99
    public function delete($environmentUuid, $destId)
100
    {
101
        return new OperationResponse(
102
            $this->client->request('delete', "/environments/${environmentUuid}/log-forwarding-destinations/${destId}")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...destinations/'.$destId) 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

102
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/environments/${environmentUuid}/log-forwarding-destinations/${destId}")
Loading history...
103
        );
104
    }
105
106
   /**
107
    * Disables a log forwarding destination.
108
    *
109
    * @param string $environmentUuid
110
    * @param int    $destId
111
    * @return OperationResponse
112
    */
113
    public function disable($environmentUuid, $destId)
114
    {
115
        return new OperationResponse(
116
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...tId.'/actions/disable') 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

116
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
117
                'post',
118
                "/environments/${environmentUuid}/log-forwarding-destinations/${destId}/actions/disable"
119
            )
120
        );
121
    }
122
123
   /**
124
    * Disables a log forwarding destination.
125
    *
126
    * @param string $environmentUuid
127
    * @param int    $destId
128
    * @return OperationResponse
129
    */
130
    public function enable($environmentUuid, $destId)
131
    {
132
        return new OperationResponse(
133
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...stId.'/actions/enable') 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

133
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
134
                'post',
135
                "/environments/${environmentUuid}/log-forwarding-destinations/${destId}/actions/enable"
136
            )
137
        );
138
    }
139
140
   /**
141
    * Updates a log forwarding destination.
142
    *
143
    * @param string $environmentUuid
144
    * @param int    $destId
145
    * @param string $label
146
    * @param array  $sources
147
    * @param string $consumer
148
    * @param array  $creds
149
    * @param string $address
150
    * @return OperationResponse
151
    */
152
    public function update($environmentUuid, $destId, $label, $sources, $consumer, $creds, $address)
153
    {
154
155
        $options = [
156
            'form_params' => [
157
                'label' => $label,
158
                'sources' => $sources,
159
                'consumer' => $consumer,
160
                'credentials' => $creds,
161
                'address' => $address
162
            ],
163
        ];
164
165
        return new OperationResponse(
166
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ns/'.$destId, $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

166
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
167
                'put',
168
                "/environments/${environmentUuid}/log-forwarding-destinations/${destId}",
169
                $options
170
            )
171
        );
172
    }
173
}
174