Completed
Pull Request — master (#34)
by Adam
09:18
created

Teams   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 121
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 28
dl 0
loc 121
rs 10
c 1
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 4 1
A getApplications() 0 4 1
A addApplication() 0 10 1
A invite() 0 11 1
A rename() 0 10 1
A create() 0 10 1
A getAll() 0 4 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 Teams
13
 * @package AcquiaCloudApi\CloudApi
14
 */
15
class Teams extends CloudApiBase implements CloudApiInterface
16
{
17
18
    /**
19
     * Create a new team.
20
     *
21
     * @param string $organizationUuid
22
     * @param string $name
23
     * @return OperationResponse
24
     */
25
    public function create($organizationUuid, $name)
26
    {
27
        $options = [
28
            'form_params' => [
29
                'name' => $name,
30
            ],
31
        ];
32
33
        return new OperationResponse(
34
            $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

34
            /** @scrutinizer ignore-type */ $this->client->request('post', "/organizations/${organizationUuid}/teams", $options)
Loading history...
35
        );
36
    }
37
38
    /**
39
     * Show all teams.
40
     *
41
     * @return TeamsResponse
42
     */
43
    public function getAll()
44
    {
45
        return new TeamsResponse(
46
            $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 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

46
            /** @scrutinizer ignore-type */ $this->client->request('get', '/teams')
Loading history...
47
        );
48
    }
49
50
    /**
51
     * Rename an existing team.
52
     *
53
     * @param string $teamUuid
54
     * @param string $name
55
     * @return OperationResponse
56
     */
57
    public function rename($teamUuid, $name)
58
    {
59
        $options = [
60
            'form_params' => [
61
                'name' => $name,
62
            ],
63
        ];
64
65
        return new OperationResponse(
66
            $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

66
            /** @scrutinizer ignore-type */ $this->client->request('put', "/teams/${teamUuid}", $options)
Loading history...
67
        );
68
    }
69
70
71
    /**
72
     * Delete a team.
73
     *
74
     * @param string $teamUuid
75
     * @return OperationResponse
76
     */
77
    public function delete($teamUuid)
78
    {
79
        return new OperationResponse(
80
            $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

80
            /** @scrutinizer ignore-type */ $this->client->request('delete', "/teams/${teamUuid}")
Loading history...
81
        );
82
    }
83
84
    /**
85
     * Add an application to a team.
86
     *
87
     * @param string $teamUuid
88
     * @param string $applicationUuid
89
     * @return OperationResponse
90
     */
91
    public function addApplication($teamUuid, $applicationUuid)
92
    {
93
        $options = [
94
            'form_params' => [
95
                'uuid' => $applicationUuid,
96
            ],
97
        ];
98
99
        return new OperationResponse(
100
            $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

100
            /** @scrutinizer ignore-type */ $this->client->request('post', "/teams/${teamUuid}/applications", $options)
Loading history...
101
        );
102
    }
103
104
    /**
105
     * Invites a user to join a team.
106
     *
107
     * @param string $teamUuid
108
     * @param string $email
109
     * @param array  $roles
110
     * @return OperationResponse
111
     */
112
    public function invite($teamUuid, $email, $roles)
113
    {
114
        $options = [
115
            'form_params' => [
116
                'email' => $email,
117
                'roles' => $roles
118
            ],
119
        ];
120
121
        return new OperationResponse(
122
            $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

122
            /** @scrutinizer ignore-type */ $this->client->request('post', "/teams/${teamUuid}/invites", $options)
Loading history...
123
        );
124
    }
125
126
    /**
127
     * Show all applications associated with a team.
128
     *
129
     * @param string $teamUuid
130
     * @return ApplicationsResponse
131
     */
132
    public function getApplications($teamUuid)
133
    {
134
        return new ApplicationsResponse(
135
            $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 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

135
            /** @scrutinizer ignore-type */ $this->client->request('get', "/teams/${teamUuid}/applications")
Loading history...
136
        );
137
    }
138
}
139