Passed
Push — master ( 23fcc1...e399e4 )
by Adam
04:08 queued 11s
created

Insights::getAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
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 a particular site.
38
     *
39
     * @param string $siteId
40
     * @return InsightResponse
41
     */
42
    public function get($siteId)
43
    {
44
        return new InsightResponse(
45
            $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

45
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
46
                'get',
47
                "/insight/${siteId}"
48
            )
49
        );
50
    }
51
52
    /**
53
     * Returns a list of Insight alerts for this site.
54
     *
55
     * @param string $siteId
56
     * @return InsightAlertsResponse
57
     */
58
    public function getAllAlerts($siteId)
59
    {
60
        return new InsightAlertsResponse(
61
            $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

61
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
62
                'get',
63
                "/insight/${siteId}/alerts"
64
            )
65
        );
66
    }
67
68
    /**
69
     * Returns a specific Insight alert for this site.
70
     *
71
     * @param string $siteId
72
     * @param string $alertUuid
73
     * @return InsightAlertResponse
74
     */
75
    public function getAlert($siteId, $alertUuid)
76
    {
77
        return new InsightAlertResponse(
78
            $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

78
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
79
                'get',
80
                "/insight/${siteId}/alerts/${alertUuid}"
81
            )
82
        );
83
    }
84
85
    /**
86
     * Ignores an alert. An ignored alert will be included will not be counted in the Insight score calculation.
87
     *
88
     * @param string $siteId
89
     * @param string $alertUuid
90
     * @return OperationResponse
91
     */
92
    public function ignoreAlert($siteId, $alertUuid)
93
    {
94
        return new OperationResponse(
95
            $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

95
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
96
                'post',
97
                "/insight/${siteId}/alerts/${alertUuid}/actions/ignore"
98
            )
99
        );
100
    }
101
102
    /**
103
     * Restores an alert. A restored alert will be included in the calculation of the Insight score.
104
     *
105
     * @param string $siteId
106
     * @param string $alertUuid
107
     * @return OperationResponse
108
     */
109
    public function restoreAlert($siteId, $alertUuid)
110
    {
111
        return new OperationResponse(
112
            $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

112
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
113
                'post',
114
                "/insight/${siteId}/alerts/${alertUuid}/actions/restore"
115
            )
116
        );
117
    }
118
119
    /**
120
     * Revokes an Insight install so it can no longer submit data using the Acquia Connector module.
121
     *
122
     * @param string $siteId
123
     * @return OperationResponse
124
     */
125
    public function revoke($siteId)
126
    {
127
        return new OperationResponse(
128
            $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

128
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
129
                'post',
130
                "/insight/${siteId}/actions/revoke"
131
            )
132
        );
133
    }
134
135
    /**
136
     * Un-revokes an Insight site so it can once again submit data using the Acquia Connector module.
137
     * Note that the site must also be unblocked using the Acquia Connector module.
138
     *
139
     * @param string $siteId
140
     * @return OperationResponse
141
     */
142
    public function unrevoke($siteId)
143
    {
144
        return new OperationResponse(
145
            $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

145
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
146
                'post',
147
                "/insight/${siteId}/actions/unrevoke"
148
            )
149
        );
150
    }
151
152
    /**
153
     * Returns a list of Drupal modules for this site.
154
     *
155
     * @param string $siteId
156
     * @return InsightModulesResponse
157
     */
158
    public function getModules($siteId)
159
    {
160
        return new InsightModulesResponse(
161
            $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

161
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
162
                'get',
163
                "/insight/${siteId}/modules"
164
            )
165
        );
166
    }
167
}
168