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

Team   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 131
Duplicated Lines 0 %

Importance

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

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
    /**
19
     * Client constructor.
20
     *
21
     * @param ConnectorInterface $connector
0 ignored issues
show
Bug introduced by
The type AcquiaCloudApi\Endpoints\ConnectorInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
     */
23
    public function __construct(ClientInterface $client)
24
    {
25
        $this->client = $client;
0 ignored issues
show
Bug Best Practice introduced by
The property client does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
26
    }
27
28
    /**
29
     * Show all teams.
30
     *
31
     * @return TeamsResponse
32
     */
33
    public function getTeams()
34
    {
35
        return new TeamsResponse(
36
            $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

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

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

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

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

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

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

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