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

Applications   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 112
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 31
dl 0
loc 112
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 6 1
A rename() 0 14 1
A getAll() 0 3 1
A createTag() 0 15 1
A getAllTags() 0 7 1
A deleteTag() 0 7 1
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Connector\ClientInterface;
6
use AcquiaCloudApi\Response\ApplicationResponse;
7
use AcquiaCloudApi\Response\ApplicationsResponse;
8
use AcquiaCloudApi\Response\TagResponse;
9
use AcquiaCloudApi\Response\TagsResponse;
10
use AcquiaCloudApi\Response\OperationResponse;
11
12
/**
13
 * Class Applications
14
 * @package AcquiaCloudApi\CloudApi
15
 */
16
class Applications extends CloudApiBase implements CloudApiInterface
17
{
18
19
    /**
20
     * Shows all applications.
21
     *
22
     * @return ApplicationsResponse
23
     */
24
    public function getAll()
25
    {
26
        return new ApplicationsResponse($this->client->request('get', '/applications'));
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('get', '/applications') can also be of type object; however, parameter $applications 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
        return new ApplicationsResponse(/** @scrutinizer ignore-type */ $this->client->request('get', '/applications'));
Loading history...
27
    }
28
29
    /**
30
     * Shows information about an application.
31
     *
32
     * @param string $applicationUuid
33
     * @return ApplicationResponse
34
     */
35
    public function get($applicationUuid)
36
    {
37
        return new ApplicationResponse(
38
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ons/'.$applicationUuid) can also be of type array; however, parameter $application 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

38
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
39
                'get',
40
                "/applications/${applicationUuid}"
41
            )
42
        );
43
    }
44
45
    /**
46
     * Renames an application.
47
     *
48
     * @param string $applicationUuid
49
     * @param string $name
50
     * @return OperationResponse
51
     */
52
    public function rename($applicationUuid, $name)
53
    {
54
55
        $options = [
56
            'form_params' => [
57
                'name' => $name,
58
            ],
59
        ];
60
61
        return new OperationResponse(
62
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...licationUuid, $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

62
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
63
                'put',
64
                "/applications/${applicationUuid}",
65
                $options
66
            )
67
        );
68
    }
69
70
    /**
71
     * Returns a list of application tags associated with this application.
72
     *
73
     * @param string $applicationUuid
74
     * @return TagsResponse
75
     */
76
    public function getAllTags($applicationUuid)
77
    {
78
79
        return new TagsResponse(
80
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...pplicationUuid.'/tags') can also be of type object; however, parameter $tags 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

80
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
81
                'get',
82
                "/applications/${applicationUuid}/tags"
83
            )
84
        );
85
    }
86
87
    /**
88
     * Creates a new application tag.
89
     *
90
     * @param string $applicationUuid
91
     * @param string $name
92
     * @param string $color
93
     * @return OperationResponse
94
     */
95
    public function createTag($applicationUuid, $name, $color)
96
    {
97
98
        $options = [
99
            'form_params' => [
100
                'name' => $name,
101
                'color' => $color,
102
            ],
103
        ];
104
105
        return new OperationResponse(
106
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...Uuid.'/tags', $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

106
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
107
                'post',
108
                "/applications/${applicationUuid}/tags",
109
                $options
110
            )
111
        );
112
    }
113
114
    /**
115
     * Deletes an application tag.
116
     *
117
     * @param string $applicationUuid
118
     * @param string $tagName
119
     * @return OperationResponse
120
     */
121
    public function deleteTag($applicationUuid, $tagName)
122
    {
123
124
        return new OperationResponse(
125
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...Uuid.'/tags/'.$tagName) 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

125
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
126
                'delete',
127
                "/applications/${applicationUuid}/tags/${tagName}"
128
            )
129
        );
130
    }
131
}
132