Passed
Push — master ( 170e92...70664d )
by Adam
04:44
created

Insights::getEnvironment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Connector\ClientInterface;
6
use AcquiaCloudApi\Response\InsightsResponse;
7
use AcquiaCloudApi\Response\InsightResponse;
8
use AcquiaCloudApi\Response\InsightAlertsResponse;
9
use AcquiaCloudApi\Response\InsightAlertResponse;
10
use AcquiaCloudApi\Response\InsightModulesResponse;
11
use AcquiaCloudApi\Response\OperationResponse;
12
13
/**
14
 * Class Insights
15
 * @package AcquiaCloudApi\CloudApi
16
 */
17
class Insights extends CloudApiBase implements CloudApiInterface
18
{
19
20
    /**
21
     * Returns Insight data for all sites associated with the application by its UUID.
22
     *
23
     * @param string $applicationUuid
24
     * @return InsightsResponse
25
     */
26
    public function getAll($applicationUuid)
27
    {
28
        return new InsightsResponse(
29
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...icationUuid.'/insight') can also be of type object; however, parameter $insights 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

29
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
30
                'get',
31
                "/applications/${applicationUuid}/insight"
32
            )
33
        );
34
    }
35
36
    /**
37
     * Returns Insight data for all sites associated with the environment by its UUID.
38
     *
39
     * @param string $environmentUuid
40
     * @return InsightsResponse
41
     */
42
    public function getEnvironment($environmentUuid)
43
    {
44
        return new InsightsResponse(
45
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ronmentUuid.'/insight') can also be of type object; however, parameter $insights 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

45
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
46
                'get',
47
                "/environment/${environmentUuid}/insight"
48
            )
49
        );
50
    }
51
52
    /**
53
     * Returns insight data for a particular site.
54
     *
55
     * @param string $siteId
56
     * @return InsightResponse
57
     */
58
    public function get($siteId)
59
    {
60
        return new InsightResponse(
61
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...', '/insight/'.$siteId) can also be of type array; however, parameter $insight 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

61
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
62
                'get',
63
                "/insight/${siteId}"
64
            )
65
        );
66
    }
67
68
    /**
69
     * Returns a list of Insight alerts for this site.
70
     *
71
     * @param string $siteId
72
     * @return InsightAlertsResponse
73
     */
74
    public function getAllAlerts($siteId)
75
    {
76
        return new InsightAlertsResponse(
77
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ht/'.$siteId.'/alerts') can also be of type object; however, parameter $alerts 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

77
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
78
                'get',
79
                "/insight/${siteId}/alerts"
80
            )
81
        );
82
    }
83
84
    /**
85
     * Returns a specific Insight alert for this site.
86
     *
87
     * @param string $siteId
88
     * @param string $alertUuid
89
     * @return InsightAlertResponse
90
     */
91
    public function getAlert($siteId, $alertUuid)
92
    {
93
        return new InsightAlertResponse(
94
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('....'/alerts/'.$alertUuid) can also be of type array; however, parameter $alert 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

94
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
95
                'get',
96
                "/insight/${siteId}/alerts/${alertUuid}"
97
            )
98
        );
99
    }
100
101
    /**
102
     * Ignores an alert. An ignored alert will be included will not be counted in the Insight score calculation.
103
     *
104
     * @param string $siteId
105
     * @param string $alertUuid
106
     * @return OperationResponse
107
     */
108
    public function ignoreAlert($siteId, $alertUuid)
109
    {
110
        return new OperationResponse(
111
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...Uuid.'/actions/ignore') 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

111
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
112
                'post',
113
                "/insight/${siteId}/alerts/${alertUuid}/actions/ignore"
114
            )
115
        );
116
    }
117
118
    /**
119
     * Restores an alert. A restored alert will be included in the calculation of the Insight score.
120
     *
121
     * @param string $siteId
122
     * @param string $alertUuid
123
     * @return OperationResponse
124
     */
125
    public function restoreAlert($siteId, $alertUuid)
126
    {
127
        return new OperationResponse(
128
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...uid.'/actions/restore') 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

128
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
129
                'post',
130
                "/insight/${siteId}/alerts/${alertUuid}/actions/restore"
131
            )
132
        );
133
    }
134
135
    /**
136
     * Revokes an Insight install so it can no longer submit data using the Acquia Connector module.
137
     *
138
     * @param string $siteId
139
     * @return OperationResponse
140
     */
141
    public function revoke($siteId)
142
    {
143
        return new OperationResponse(
144
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...teId.'/actions/revoke') 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

144
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
145
                'post',
146
                "/insight/${siteId}/actions/revoke"
147
            )
148
        );
149
    }
150
151
    /**
152
     * Un-revokes an Insight site so it can once again submit data using the Acquia Connector module.
153
     * Note that the site must also be unblocked using the Acquia Connector module.
154
     *
155
     * @param string $siteId
156
     * @return OperationResponse
157
     */
158
    public function unrevoke($siteId)
159
    {
160
        return new OperationResponse(
161
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...Id.'/actions/unrevoke') 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

161
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
162
                'post',
163
                "/insight/${siteId}/actions/unrevoke"
164
            )
165
        );
166
    }
167
168
    /**
169
     * Returns a list of Drupal modules for this site.
170
     *
171
     * @param string $siteId
172
     * @return InsightModulesResponse
173
     */
174
    public function getModules($siteId)
175
    {
176
        return new InsightModulesResponse(
177
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...t/'.$siteId.'/modules') can also be of type object; however, parameter $modules 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

177
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
178
                'get',
179
                "/insight/${siteId}/modules"
180
            )
181
        );
182
    }
183
}
184