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

Organization::getInvitees()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 1
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\InvitationsResponse;
9
use AcquiaCloudApi\Response\MembersResponse;
10
use AcquiaCloudApi\Response\OrganizationsResponse;
11
use AcquiaCloudApi\Response\RolesResponse;
12
use AcquiaCloudApi\Response\TeamsResponse;
13
use AcquiaCloudApi\Response\OperationResponse;
14
15
/**
16
 * Class Client
17
 * @package AcquiaCloudApi\CloudApi
18
 */
19
class Organization implements CloudApi
20
{
21
22
    /**
23
     * Client constructor.
24
     *
25
     * @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...
26
     */
27
    public function __construct(ClientInterface $client)
28
    {
29
        $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...
30
    }
31
32
    /**
33
     * Show all organizations.
34
     *
35
     * @return OrganizationsResponse
36
     */
37
    public function getOrganizations()
38
    {
39
        return new OrganizationsResponse($this->client->request('get', '/organizations'));
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('get', '/organizations') can also be of type AcquiaCloudApi\Connector\StreamInterface and object; however, parameter $organizations 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
        return new OrganizationsResponse(/** @scrutinizer ignore-type */ $this->client->request('get', '/organizations'));
Loading history...
40
    }
41
42
    /**
43
     * Show all applications in an organisation.
44
     *
45
     * @param string $organizationUuid
46
     *
47
     * @return ApplicationsResponse
48
     */
49
    public function getApplications($organizationUuid)
50
    {
51
        return new ApplicationsResponse(
52
            $this->client->request('get', "/organizations/${organizationUuid}/applications")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...onUuid.'/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

52
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/applications")
Loading history...
53
        );
54
    }
55
56
    /**
57
     * Show all roles in an organization.
58
     *
59
     * @param string $organizationUuid
60
     * @return RolesResponse
61
     */
62
    public function getRoles($organizationUuid)
63
    {
64
        return new RolesResponse(
65
            $this->client->request('get', "/organizations/${organizationUuid}/roles")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...anizationUuid.'/roles') can also be of type AcquiaCloudApi\Connector\StreamInterface and object; however, parameter $roles 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

65
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/roles")
Loading history...
66
        );
67
    }
68
69
    /**
70
     * Create a new role.
71
     *
72
     * @param string      $organizationUuid
73
     * @param string      $name
74
     * @param array       $permissions
75
     * @param null|string $description
76
     * @return OperationResponse
77
     */
78
    public function createRole($organizationUuid, $name, array $permissions, $description = null)
79
    {
80
        $options = [
81
            'form_params' => [
82
                'name' => $name,
83
                'permissions' => $permissions,
84
                'description' => $description,
85
            ],
86
        ];
87
88
        return new OperationResponse(
89
            $this->client->request('post', "/organizations/${organizationUuid}/roles", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...uid.'/roles', $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

89
            /** @scrutinizer ignore-type */ $this->client->request('post', "/organizations/${organizationUuid}/roles", $options)
Loading history...
90
        );
91
    }
92
93
    /**
94
     * Show all teams in an organization.
95
     *
96
     * @param string $organizationUuid
97
     * @return TeamsResponse
98
     */
99
    public function getTeams($organizationUuid)
100
    {
101
        return new TeamsResponse(
102
            $this->client->request('get', "/organizations/${organizationUuid}/teams")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...anizationUuid.'/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

102
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/teams")
Loading history...
103
        );
104
    }
105
106
    /**
107
     * Create a new team.
108
     *
109
     * @param string $organizationUuid
110
     * @param string $name
111
     * @return OperationResponse
112
     */
113
    public function createTeam($organizationUuid, $name)
114
    {
115
        $options = [
116
            'form_params' => [
117
                'name' => $name,
118
            ],
119
        ];
120
121
        return new OperationResponse(
122
            $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

122
            /** @scrutinizer ignore-type */ $this->client->request('post', "/organizations/${organizationUuid}/teams", $options)
Loading history...
123
        );
124
    }
125
126
    /**
127
     * Show all members of an organisation.
128
     *
129
     * @param string $organizationUuid
130
     * @return MembersResponse
131
     */
132
    public function getMembers($organizationUuid)
133
    {
134
        return new MembersResponse(
135
            $this->client->request('get', "/organizations/${organizationUuid}/members")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...izationUuid.'/members') can also be of type AcquiaCloudApi\Connector\StreamInterface and object; however, parameter $members 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', "/organizations/${organizationUuid}/members")
Loading history...
136
        );
137
    }
138
139
    /**
140
     * Show all members invited to an organisation.
141
     *
142
     * @param string $organizationUuid
143
     * @return InvitationsResponse
144
     */
145
    public function getInvitees($organizationUuid)
146
    {
147
        return new InvitationsResponse(
148
            $this->client->request('get', "/organizations/${organizationUuid}/team-invites")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...onUuid.'/team-invites') can also be of type AcquiaCloudApi\Connector\StreamInterface and object; however, parameter $invitations 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', "/organizations/${organizationUuid}/team-invites")
Loading history...
149
        );
150
    }
151
152
    /**
153
     * Delete a member from an organisation.
154
     *
155
     * @param string $organizationUuid
156
     * @param string $memberUuid
157
     * @return OperationResponse
158
     */
159
    public function deleteMember($organizationUuid, $memberUuid)
160
    {
161
        return new OperationResponse(
162
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('.../members/'.$memberUuid) 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

162
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
163
                'delete',
164
                "/organizations/${organizationUuid}/members/${memberUuid}"
165
            )
166
        );
167
    }
168
}
169