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

IdentityProviders   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 109
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 32
dl 0
loc 109
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getAll() 0 6 1
A delete() 0 6 1
A update() 0 17 1
A enable() 0 6 1
A get() 0 6 1
A disable() 0 6 1
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Connector\ClientInterface;
6
use AcquiaCloudApi\Response\OperationResponse;
7
use AcquiaCloudApi\Response\IdentityProvidersResponse;
8
use AcquiaCloudApi\Response\IdentityProviderResponse;
9
10
/**
11
 * Class IdentityProviders
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class IdentityProviders extends CloudApiBase implements CloudApiInterface
15
{
16
17
    /**
18
     * Returns a list of identity providers for the user.
19
     *
20
     * @return IdentityProvidersResponse
21
     */
22
    public function getAll()
23
    {
24
        return new IdentityProvidersResponse(
25
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('... '/identity-providers') can also be of type object; however, parameter $idps 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

25
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
26
                'get',
27
                "/identity-providers"
28
            )
29
        );
30
    }
31
32
    /**
33
     * Returns a specific identity provider by UUID.
34
     *
35
     * @param string $idpUuid The identity provider ID
36
     * @return IdentityProviderResponse
37
     */
38
    public function get($idpUuid)
39
    {
40
        return new IdentityProviderResponse(
41
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...y-providers/'.$idpUuid) can also be of type array; however, parameter $idp 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

41
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
42
                'get',
43
                "/identity-providers/${idpUuid}"
44
            )
45
        );
46
    }
47
48
    /**
49
     * Delete a specific identity provider by UUID.
50
     *
51
     * @param string $idpUuid
52
     * @return OperationResponse
53
     */
54
    public function delete($idpUuid)
55
    {
56
        return new OperationResponse(
57
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...y-providers/'.$idpUuid) 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

57
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
58
                'delete',
59
                "/identity-providers/${idpUuid}"
60
            )
61
        );
62
    }
63
64
    /**
65
     * Disables an identity provider by UUID.
66
     *
67
     * @param string $idpUuid
68
     * @return OperationResponse
69
     */
70
    public function disable($idpUuid)
71
    {
72
        return new OperationResponse(
73
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...uid.'/actions/disable') 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

73
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
74
                'post',
75
                "/identity-providers/${idpUuid}/actions/disable"
76
            )
77
        );
78
    }
79
80
    /**
81
     * Enables an identity provider by UUID.
82
     *
83
     * @param string $idpUuid
84
     * @return OperationResponse
85
     */
86
    public function enable($idpUuid)
87
    {
88
        return new OperationResponse(
89
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...Uuid.'/actions/enable') 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

89
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
90
                'post',
91
                "/identity-providers/${idpUuid}/actions/enable"
92
            )
93
        );
94
    }
95
96
    /**
97
     * Updates a identity provider by UUID.
98
     *
99
     * @param string $idpUuid
100
     * @param string $label
101
     * @param string $entityId
102
     * @param string $ssoUrl
103
     * @param string $certificate
104
     * @return OperationResponse
105
     */
106
    public function update($idpUuid, $label, $entityId, $ssoUrl, $certificate)
107
    {
108
109
        $options = [
110
            'form_params' => [
111
                'label' => $label,
112
                'entity_id' => $entityId,
113
                'sso_url' => $ssoUrl,
114
                'certificate' => $certificate,
115
            ],
116
        ];
117
118
        return new OperationResponse(
119
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...s/'.$idpUuid, $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

119
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
120
                'put',
121
                "/identity-providers/${idpUuid}",
122
                $options
123
            )
124
        );
125
    }
126
}
127