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

Roles::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
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 Roles
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class Roles extends CloudApiBase implements CloudApiInterface
15
{
16
17
    /**
18
     * Show all roles in an organization.
19
     *
20
     * @param string $organizationUuid
21
     * @return RolesResponse
22
     */
23
    public function getAll($organizationUuid)
24
    {
25
        return new RolesResponse(
26
            $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

26
            /** @scrutinizer ignore-type */ $this->client->request('get', "/organizations/${organizationUuid}/roles")
Loading history...
27
        );
28
    }
29
30
    /**
31
     * Return details about a specific role.
32
     *
33
     * @param string $roleUuid
34
     * @return RoleResponse
35
     */
36
    public function get($roleUuid)
37
    {
38
        return new RoleResponse(
39
            $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

39
            /** @scrutinizer ignore-type */ $this->client->request('get', "/roles/${roleUuid}")
Loading history...
40
        );
41
    }
42
43
    /**
44
     * Create a new role.
45
     *
46
     * @param string      $organizationUuid
47
     * @param string      $name
48
     * @param array       $permissions
49
     * @param null|string $description
50
     * @return OperationResponse
51
     */
52
    public function create($organizationUuid, $name, array $permissions, $description = null)
53
    {
54
        $options = [
55
            'form_params' => [
56
                'name' => $name,
57
                'permissions' => $permissions,
58
                'description' => $description,
59
            ],
60
        ];
61
62
        return new OperationResponse(
63
            $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

63
            /** @scrutinizer ignore-type */ $this->client->request('post', "/organizations/${organizationUuid}/roles", $options)
Loading history...
64
        );
65
    }
66
67
    /**
68
     * Update the permissions associated with a role.
69
     *
70
     * @param string $roleUuid
71
     * @param array  $permissions
72
     * @return OperationResponse
73
     */
74
    public function update($roleUuid, array $permissions)
75
    {
76
        $options = [
77
            'form_params' => [
78
                'permissions' => $permissions,
79
            ],
80
        ];
81
82
        return new OperationResponse(
83
            $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

83
            /** @scrutinizer ignore-type */ $this->client->request('put', "/roles/${roleUuid}", $options)
Loading history...
84
        );
85
    }
86
87
    /**
88
     * Delete a role.
89
     *
90
     * @param string $roleUuid
91
     * @return OperationResponse
92
     */
93
    public function delete($roleUuid)
94
    {
95
        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

95
        return new OperationResponse(/** @scrutinizer ignore-type */ $this->client->request('delete', "/roles/${roleUuid}"));
Loading history...
96
    }
97
}
98