Passed
Push — master ( a4d359...48ca8a )
by Dane
02:05
created

Subscriptions   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 49
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A rename() 0 14 1
A getAll() 0 3 1
A get() 0 6 1
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Response\OperationResponse;
6
use AcquiaCloudApi\Response\SubscriptionResponse;
7
use AcquiaCloudApi\Response\SubscriptionsResponse;
8
9
class Subscriptions extends CloudApiBase implements CloudApiInterface
10
{
11
    /**
12
     * Shows all Subscriptions.
13
     *
14
     * @return SubscriptionsResponse<SubscriptionResponse>
15
     */
16
    public function getAll(): SubscriptionsResponse
17
    {
18
        return new SubscriptionsResponse($this->client->request('get', '/subscriptions'));
19
    }
20
21
    /**
22
     * Shows information about an subscription.
23
     *
24
     * @param  string $subscriptionUuid
25
     * @return SubscriptionResponse
26
     */
27
    public function get($subscriptionUuid): SubscriptionResponse
28
    {
29
        return new SubscriptionResponse(
30
            $this->client->request(
31
                'get',
32
                "/subscriptions/${subscriptionUuid}"
33
            )
34
        );
35
    }
36
37
    /**
38
     * Renames an subscription.
39
     *
40
     * @param  string $subscriptionUuid
41
     * @param  string $name
42
     * @return OperationResponse
43
     */
44
    public function rename($subscriptionUuid, $name): OperationResponse
45
    {
46
47
        $options = [
48
            'json' => [
49
                'name' => $name,
50
            ],
51
        ];
52
53
        return new OperationResponse(
54
            $this->client->request(
55
                'put',
56
                "/subscriptions/${subscriptionUuid}",
57
                $options
58
            )
59
        );
60
    }
61
}
62