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

Organizations::deleteMember()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Connector\ClientInterface;
6
use AcquiaCloudApi\Response\ApplicationsResponse;
7
use AcquiaCloudApi\Response\InvitationsResponse;
8
use AcquiaCloudApi\Response\MembersResponse;
9
use AcquiaCloudApi\Response\OrganizationsResponse;
10
use AcquiaCloudApi\Response\TeamsResponse;
11
use AcquiaCloudApi\Response\OperationResponse;
12
13
/**
14
 * Class Organizations
15
 * @package AcquiaCloudApi\CloudApi
16
 */
17
class Organizations extends CloudApiBase implements CloudApiInterface
18
{
19
20
    /**
21
     * Show all organizations.
22
     *
23
     * @return OrganizationsResponse
24
     */
25
    public function getAll()
26
    {
27
        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 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

27
        return new OrganizationsResponse(/** @scrutinizer ignore-type */ $this->client->request('get', '/organizations'));
Loading history...
28
    }
29
30
    /**
31
     * Show all applications in an organisation.
32
     *
33
     * @param string $organizationUuid
34
     *
35
     * @return ApplicationsResponse
36
     */
37
    public function getApplications($organizationUuid)
38
    {
39
        return new ApplicationsResponse(
40
            $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 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

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

53
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/members")
Loading history...
54
        );
55
    }
56
57
    /**
58
     * Show all members invited to an organisation.
59
     *
60
     * @param string $organizationUuid
61
     * @return InvitationsResponse
62
     */
63
    public function getMemberInvitations($organizationUuid)
64
    {
65
        return new InvitationsResponse(
66
            $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 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

66
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/team-invites")
Loading history...
67
        );
68
    }
69
70
    /**
71
     * Delete a member from an organisation.
72
     *
73
     * @param string $organizationUuid
74
     * @param string $memberUuid
75
     * @return OperationResponse
76
     */
77
    public function deleteMember($organizationUuid, $memberUuid)
78
    {
79
        return new OperationResponse(
80
            $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

80
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
81
                'delete',
82
                "/organizations/${organizationUuid}/members/${memberUuid}"
83
            )
84
        );
85
    }
86
87
    /**
88
     * Show all teams in an organization.
89
     *
90
     * @param string $organizationUuid
91
     * @return TeamsResponse
92
     */
93
    public function getTeams($organizationUuid)
94
    {
95
        return new TeamsResponse(
96
            $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 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

96
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/teams")
Loading history...
97
        );
98
    }
99
100
    /**
101
     * Invites a user to become admin of an organization.
102
     *
103
     * @param string $organizationUuid
104
     * @param string $email
105
     * @return OperationResponse
106
     */
107
    public function inviteAdmin($organizationUuid, $email)
108
    {
109
        $options = [
110
            'form_params' => [
111
                'email' => $email,
112
            ],
113
        ];
114
115
        return new OperationResponse(
116
            $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

116
            /** @scrutinizer ignore-type */ $this->client->request('post', "/teams/${organizationUuid}/invites", $options)
Loading history...
117
        );
118
    }
119
}
120