Completed
Pull Request — master (#34)
by Adam
03:44
created

Organizations::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
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\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 Organizations implements CloudApi
20
{
21
22
    /** @var ClientInterface The API client. */
23
    protected $client;
24
25
    /**
26
     * Client constructor.
27
     *
28
     * @param ClientInterface $client
29
     */
30
    public function __construct(ClientInterface $client)
31
    {
32
        $this->client = $client;
33
    }
34
35
    /**
36
     * Show all organizations.
37
     *
38
     * @return OrganizationsResponse
39
     */
40
    public function getOrganizations()
41
    {
42
        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 Psr\Http\Message\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

42
        return new OrganizationsResponse(/** @scrutinizer ignore-type */ $this->client->request('get', '/organizations'));
Loading history...
43
    }
44
45
    /**
46
     * Show all applications in an organisation.
47
     *
48
     * @param string $organizationUuid
49
     *
50
     * @return ApplicationsResponse
51
     */
52
    public function getApplications($organizationUuid)
53
    {
54
        return new ApplicationsResponse(
55
            $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 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

55
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/applications")
Loading history...
56
        );
57
    }
58
59
    /**
60
     * Show all roles in an organization.
61
     *
62
     * @param string $organizationUuid
63
     * @return RolesResponse
64
     */
65
    public function getRoles($organizationUuid)
66
    {
67
        return new RolesResponse(
68
            $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 Psr\Http\Message\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

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

92
            /** @scrutinizer ignore-type */ $this->client->request('post', "/organizations/${organizationUuid}/roles", $options)
Loading history...
93
        );
94
    }
95
96
    /**
97
     * Show all teams in an organization.
98
     *
99
     * @param string $organizationUuid
100
     * @return TeamsResponse
101
     */
102
    public function getTeams($organizationUuid)
103
    {
104
        return new TeamsResponse(
105
            $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 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

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

125
            /** @scrutinizer ignore-type */ $this->client->request('post', "/organizations/${organizationUuid}/teams", $options)
Loading history...
126
        );
127
    }
128
129
    /**
130
     * Show all members of an organisation.
131
     *
132
     * @param string $organizationUuid
133
     * @return MembersResponse
134
     */
135
    public function getMembers($organizationUuid)
136
    {
137
        return new MembersResponse(
138
            $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 Psr\Http\Message\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

138
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/members")
Loading history...
139
        );
140
    }
141
142
    /**
143
     * Show all members invited to an organisation.
144
     *
145
     * @param string $organizationUuid
146
     * @return InvitationsResponse
147
     */
148
    public function getInvitees($organizationUuid)
149
    {
150
        return new InvitationsResponse(
151
            $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 Psr\Http\Message\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

151
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/team-invites")
Loading history...
152
        );
153
    }
154
155
    /**
156
     * Delete a member from an organisation.
157
     *
158
     * @param string $organizationUuid
159
     * @param string $memberUuid
160
     * @return OperationResponse
161
     */
162
    public function deleteMember($organizationUuid, $memberUuid)
163
    {
164
        return new OperationResponse(
165
            $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

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