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

Organizations   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
c 0
b 0
f 0
dl 0
loc 93
rs 10
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A deleteMember() 0 6 1
A getMembers() 0 4 1
A __construct() 0 3 1
A getTeams() 0 4 1
A getAll() 0 3 1
A getApplications() 0 4 1
A getInvitees() 0 4 1
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 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

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 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

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 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

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 getInvitees($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 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

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 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

109
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/teams")
Loading history...
110
        );
111
    }
112
}
113