Completed
Pull Request — master (#34)
by Adam
03:21
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 Client
15
 * @package AcquiaCloudApi\CloudApi
16
 */
17
class Organizations implements CloudApi
18
{
19
20
    /** @var ClientInterface The API client. */
21
    protected $client;
22
23
    /**
24
     * Client constructor.
25
     *
26
     * @param ClientInterface $client
27
     */
28
    public function __construct(ClientInterface $client)
29
    {
30
        $this->client = $client;
31
    }
32
33
    /**
34
     * Show all organizations.
35
     *
36
     * @return OrganizationsResponse
37
     */
38
    public function getAll()
39
    {
40
        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

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

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

66
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/members")
Loading history...
67
        );
68
    }
69
70
    /**
71
     * Show all members invited to an organisation.
72
     *
73
     * @param string $organizationUuid
74
     * @return InvitationsResponse
75
     */
76
    public function getMemberInvitations($organizationUuid)
77
    {
78
        return new InvitationsResponse(
79
            $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

79
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/team-invites")
Loading history...
80
        );
81
    }
82
83
    /**
84
     * Delete a member from an organisation.
85
     *
86
     * @param string $organizationUuid
87
     * @param string $memberUuid
88
     * @return OperationResponse
89
     */
90
    public function deleteMember($organizationUuid, $memberUuid)
91
    {
92
        return new OperationResponse(
93
            $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

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

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

129
            /** @scrutinizer ignore-type */ $this->client->request('post', "/teams/${organizationUuid}/invites", $options)
Loading history...
130
        );
131
    }
132
}
133