Completed
Pull Request — master (#34)
by Adam
02:14
created

Team   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 134
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 30
c 1
b 0
f 0
dl 0
loc 134
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A createOrganizationAdminInvite() 0 10 1
A addApplicationToTeam() 0 10 1
A getApplications() 0 4 1
A renameTeam() 0 10 1
A createTeamInvite() 0 11 1
A getTeams() 0 4 1
A __construct() 0 3 1
A deleteTeam() 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 Client
13
 * @package AcquiaCloudApi\CloudApi
14
 */
15
class Team implements CloudApi
16
{
17
18
    /** @var ClientInterface The API client. */
19
    protected $client;
20
21
    /**
22
     * Client constructor.
23
     *
24
     * @param ClientInterface $connector
25
     */
26
    public function __construct(ClientInterface $client)
27
    {
28
        $this->client = $client;
29
    }
30
31
    /**
32
     * Show all teams.
33
     *
34
     * @return TeamsResponse
35
     */
36
    public function getTeams()
37
    {
38
        return new TeamsResponse(
39
            $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 AcquiaCloudApi\Connector\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

39
            /** @scrutinizer ignore-type */ $this->client->request('get', '/teams')
Loading history...
40
        );
41
    }
42
43
    /**
44
     * Rename an existing team.
45
     *
46
     * @param string $teamUuid
47
     * @param string $name
48
     * @return OperationResponse
49
     */
50
    public function renameTeam($teamUuid, $name)
51
    {
52
        $options = [
53
            'form_params' => [
54
                'name' => $name,
55
            ],
56
        ];
57
58
        return new OperationResponse(
59
            $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

59
            /** @scrutinizer ignore-type */ $this->client->request('put', "/teams/${teamUuid}", $options)
Loading history...
60
        );
61
    }
62
63
64
    /**
65
     * Delete a team.
66
     *
67
     * @param string $teamUuid
68
     * @return OperationResponse
69
     */
70
    public function deleteTeam($teamUuid)
71
    {
72
        return new OperationResponse(
73
            $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

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

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

115
            /** @scrutinizer ignore-type */ $this->client->request('post', "/teams/${teamUuid}/invites", $options)
Loading history...
116
        );
117
    }
118
119
    /**
120
     * Invites a user to become admin of an organization.
121
     *
122
     * @param string $organizationUuid
123
     * @param string $email
124
     * @return OperationResponse
125
     */
126
    public function createOrganizationAdminInvite($organizationUuid, $email)
127
    {
128
        $options = [
129
            'form_params' => [
130
                'email' => $email,
131
            ],
132
        ];
133
134
        return new OperationResponse(
135
            $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

135
            /** @scrutinizer ignore-type */ $this->client->request('post', "/teams/${organizationUuid}/invites", $options)
Loading history...
136
        );
137
    }
138
139
    /**
140
     * Show all applications associated with a team.
141
     *
142
     * @param string $teamUuid
143
     * @return ApplicationsResponse
144
     */
145
    public function getApplications($teamUuid)
146
    {
147
        return new ApplicationsResponse(
148
            $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 AcquiaCloudApi\Connector\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

148
            /** @scrutinizer ignore-type */ $this->client->request('get', "/teams/${teamUuid}/applications")
Loading history...
149
        );
150
    }
151
}
152