Passed
Pull Request — master (#34)
by Adam
02:07
created

Role::updateRole()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 10
rs 10
c 1
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\ApplicationResponse;
7
use AcquiaCloudApi\Response\ApplicationsResponse;
8
use AcquiaCloudApi\Response\RolesResponse;
9
use AcquiaCloudApi\Response\OperationResponse;
10
11
/**
12
 * Class Client
13
 * @package AcquiaCloudApi\CloudApi
14
 */
15
class Role implements CloudApi
16
{
17
18
    /** @var ClientInterface The API client. */
19
    protected $client;
20
21
    /**
22
     * Client constructor.
23
     *
24
     * @param ClientInterface $client
25
     */
26
    public function __construct(ClientInterface $client)
27
    {
28
        $this->client = $client;
29
    }
30
31
    /**
32
     * Update the permissions associated with a role.
33
     *
34
     * @param string $roleUuid
35
     * @param array  $permissions
36
     * @return OperationResponse
37
     */
38
    public function updateRole($roleUuid, array $permissions)
39
    {
40
        $options = [
41
            'form_params' => [
42
                'permissions' => $permissions,
43
            ],
44
        ];
45
46
        return new OperationResponse(
47
            $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

47
            /** @scrutinizer ignore-type */ $this->client->request('put', "/roles/${roleUuid}", $options)
Loading history...
48
        );
49
    }
50
51
    /**
52
     * Delete a role.
53
     *
54
     * @param string $roleUuid
55
     * @return OperationResponse
56
     */
57
    public function deleteRole($roleUuid)
58
    {
59
        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

59
        return new OperationResponse(/** @scrutinizer ignore-type */ $this->client->request('delete', "/roles/${roleUuid}"));
Loading history...
60
    }
61
}
62