Completed
Pull Request — master (#34)
by Adam
02:18
created

Role   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
dl 0
loc 42
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A deleteRole() 0 3 1
A updateRole() 0 10 1
A __construct() 0 3 1
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
    /**
19
     * Client constructor.
20
     *
21
     * @param ConnectorInterface $connector
0 ignored issues
show
Bug introduced by
The type AcquiaCloudApi\Endpoints\ConnectorInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
     */
23
    public function __construct(ClientInterface $client)
24
    {
25
        $this->client = $client;
0 ignored issues
show
Bug Best Practice introduced by
The property client does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
26
    }
27
28
    /**
29
     * Update the permissions associated with a role.
30
     *
31
     * @param string $roleUuid
32
     * @param array  $permissions
33
     * @return OperationResponse
34
     */
35
    public function updateRole($roleUuid, array $permissions)
36
    {
37
        $options = [
38
            'form_params' => [
39
                'permissions' => $permissions,
40
            ],
41
        ];
42
43
        return new OperationResponse(
44
            $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

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

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