Test Failed
Pull Request — master (#34)
by Adam
03:36
created

Roles::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Connector\ClientInterface;
6
use AcquiaCloudApi\Response\RolesResponse;
7
use AcquiaCloudApi\Response\RoleResponse;
8
use AcquiaCloudApi\Response\OperationResponse;
9
10
/**
11
 * Class Client
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class Roles implements CloudApi
15
{
16
17
    /** @var ClientInterface The API client. */
18
    protected $client;
19
20
    /**
21
     * Client constructor.
22
     *
23
     * @param ClientInterface $client
24
     */
25
    public function __construct(ClientInterface $client)
26
    {
27
        $this->client = $client;
28
    }
29
30
    /**
31
     * Show all roles in an organization.
32
     *
33
     * @param string $organizationUuid
34
     * @return RolesResponse
35
     */
36
    public function getAll($organizationUuid)
37
    {
38
        return new RolesResponse(
39
            $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 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

39
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/roles")
Loading history...
40
        );
41
    }
42
43
    /**
44
     * Return details about a specific role.
45
     *
46
     * @param string $roleUuid
47
     * @return RoleResponse
48
     */
49
    public function get($roleUuid)
50
    {
51
        return new RoleResponse(
52
            $this->client->request('get', "/roles/${roleUuid}")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...', '/roles/'.$roleUuid) can also be of type array; however, parameter $role 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

52
            /** @scrutinizer ignore-type */ $this->client->request('get', "/roles/${roleUuid}")
Loading history...
53
        );
54
    }
55
56
    /**
57
     * Create a new role.
58
     *
59
     * @param string      $organizationUuid
60
     * @param string      $name
61
     * @param array       $permissions
62
     * @param null|string $description
63
     * @return OperationResponse
64
     */
65
    public function create($organizationUuid, $name, array $permissions, $description = null)
66
    {
67
        $options = [
68
            'form_params' => [
69
                'name' => $name,
70
                'permissions' => $permissions,
71
                'description' => $description,
72
            ],
73
        ];
74
75
        return new OperationResponse(
76
            $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

76
            /** @scrutinizer ignore-type */ $this->client->request('post', "/organizations/${organizationUuid}/roles", $options)
Loading history...
77
        );
78
    }
79
80
    /**
81
     * Update the permissions associated with a role.
82
     *
83
     * @param string $roleUuid
84
     * @param array  $permissions
85
     * @return OperationResponse
86
     */
87
    public function update($roleUuid, array $permissions)
88
    {
89
        $options = [
90
            'form_params' => [
91
                'permissions' => $permissions,
92
            ],
93
        ];
94
95
        return new OperationResponse(
96
            $this->client->request('put', "/roles/${roleUuid}", $options)
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('.../'.$roleUuid, $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

96
            /** @scrutinizer ignore-type */ $this->client->request('put', "/roles/${roleUuid}", $options)
Loading history...
97
        );
98
    }
99
100
    /**
101
     * Delete a role.
102
     *
103
     * @param string $roleUuid
104
     * @return OperationResponse
105
     */
106
    public function delete($roleUuid)
107
    {
108
        return new OperationResponse($this->client->request('delete', "/roles/${roleUuid}"));
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...', '/roles/'.$roleUuid) 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

108
        return new OperationResponse(/** @scrutinizer ignore-type */ $this->client->request('delete', "/roles/${roleUuid}"));
Loading history...
109
    }
110
}
111