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

Teams::getApplications()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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\TeamsResponse;
9
use AcquiaCloudApi\Response\OperationResponse;
10
11
/**
12
 * Class Client
13
 * @package AcquiaCloudApi\CloudApi
14
 */
15
class Teams implements CloudApi
16
{
17
18
    /** @var ClientInterface The API client. */
19
    protected $client;
20
21
    /**
22
     * Client constructor.
23
     *
24
     * @param ClientInterface $client
25
     */
26
    public function __construct(ClientInterface $client)
27
    {
28
        $this->client = $client;
29
    }
30
31
    /**
32
     * Create a new team.
33
     *
34
     * @param string $organizationUuid
35
     * @param string $name
36
     * @return OperationResponse
37
     */
38
    public function create($organizationUuid, $name)
39
    {
40
        $options = [
41
            'form_params' => [
42
                'name' => $name,
43
            ],
44
        ];
45
46
        return new OperationResponse(
47
            $this->client->request('post', "/organizations/${organizationUuid}/teams", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...uid.'/teams', $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

47
            /** @scrutinizer ignore-type */ $this->client->request('post', "/organizations/${organizationUuid}/teams", $options)
Loading history...
48
        );
49
    }
50
51
    /**
52
     * Show all teams.
53
     *
54
     * @return TeamsResponse
55
     */
56
    public function getAll()
57
    {
58
        return new TeamsResponse(
59
            $this->client->request('get', '/teams')
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('get', '/teams') can also be of type Psr\Http\Message\StreamInterface and object; however, parameter $teams 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

59
            /** @scrutinizer ignore-type */ $this->client->request('get', '/teams')
Loading history...
60
        );
61
    }
62
63
    /**
64
     * Rename an existing team.
65
     *
66
     * @param string $teamUuid
67
     * @param string $name
68
     * @return OperationResponse
69
     */
70
    public function rename($teamUuid, $name)
71
    {
72
        $options = [
73
            'form_params' => [
74
                'name' => $name,
75
            ],
76
        ];
77
78
        return new OperationResponse(
79
            $this->client->request('put', "/teams/${teamUuid}", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('.../'.$teamUuid, $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

79
            /** @scrutinizer ignore-type */ $this->client->request('put', "/teams/${teamUuid}", $options)
Loading history...
80
        );
81
    }
82
83
84
    /**
85
     * Delete a team.
86
     *
87
     * @param string $teamUuid
88
     * @return OperationResponse
89
     */
90
    public function delete($teamUuid)
91
    {
92
        return new OperationResponse(
93
            $this->client->request('delete', "/teams/${teamUuid}")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...', '/teams/'.$teamUuid) 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

93
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/teams/${teamUuid}")
Loading history...
94
        );
95
    }
96
97
    /**
98
     * Add an application to a team.
99
     *
100
     * @param string $teamUuid
101
     * @param string $applicationUuid
102
     * @return OperationResponse
103
     */
104
    public function addApplication($teamUuid, $applicationUuid)
105
    {
106
        $options = [
107
            'form_params' => [
108
                'uuid' => $applicationUuid,
109
            ],
110
        ];
111
112
        return new OperationResponse(
113
            $this->client->request('post', "/teams/${teamUuid}/applications", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...pplications', $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

113
            /** @scrutinizer ignore-type */ $this->client->request('post', "/teams/${teamUuid}/applications", $options)
Loading history...
114
        );
115
    }
116
117
    /**
118
     * Invites a user to join a team.
119
     *
120
     * @param string $teamUuid
121
     * @param string $email
122
     * @param array  $roles
123
     * @return OperationResponse
124
     */
125
    public function createTeamInvite($teamUuid, $email, $roles)
126
    {
127
        $options = [
128
            'form_params' => [
129
                'email' => $email,
130
                'roles' => $roles
131
            ],
132
        ];
133
134
        return new OperationResponse(
135
            $this->client->request('post', "/teams/${teamUuid}/invites", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...d.'/invites', $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

135
            /** @scrutinizer ignore-type */ $this->client->request('post', "/teams/${teamUuid}/invites", $options)
Loading history...
136
        );
137
    }
138
139
    /**
140
     * Invites a user to become admin of an organization.
141
     *
142
     * @param string $organizationUuid
143
     * @param string $email
144
     * @return OperationResponse
145
     */
146
    public function createOrganizationAdminInvite($organizationUuid, $email)
147
    {
148
        $options = [
149
            'form_params' => [
150
                'email' => $email,
151
            ],
152
        ];
153
154
        return new OperationResponse(
155
            $this->client->request('post', "/teams/${organizationUuid}/invites", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...d.'/invites', $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

155
            /** @scrutinizer ignore-type */ $this->client->request('post', "/teams/${organizationUuid}/invites", $options)
Loading history...
156
        );
157
    }
158
159
    /**
160
     * Show all applications associated with a team.
161
     *
162
     * @param string $teamUuid
163
     * @return ApplicationsResponse
164
     */
165
    public function getApplications($teamUuid)
166
    {
167
        return new ApplicationsResponse(
168
            $this->client->request('get', "/teams/${teamUuid}/applications")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...amUuid.'/applications') can also be of type Psr\Http\Message\StreamInterface and 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

168
            /** @scrutinizer ignore-type */ $this->client->request('get', "/teams/${teamUuid}/applications")
Loading history...
169
        );
170
    }
171
}
172