Passed
Pull Request — master (#34)
by Adam
03:39
created

Metrics   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 22
dl 0
loc 102
rs 10
c 1
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getStackMetricsData() 0 5 1
A getAggregateData() 0 5 1
A getStackMetricsDataByMetric() 0 5 1
A getViewsByEnvironment() 0 5 1
A getVisitsByEnvironment() 0 5 1
A getDataByEnvironment() 0 5 1
A getAggregateUsageMetrics() 0 5 1
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Connector\ClientInterface;
6
use AcquiaCloudApi\Response\MetricsResponse;
7
use AcquiaCloudApi\Response\MetricResponse;
8
9
/**
10
 * Class Metrics
11
 * @package AcquiaCloudApi\CloudApi
12
 */
13
class Metrics extends CloudApiBase implements CloudApiInterface
14
{
15
16
    /**
17
     * Retrieves aggregate usage data for an application.
18
     *
19
     * @return MetricsResponse
20
     * @param string $applicationUuid
21
     */
22
    public function getAggregateData($applicationUuid)
23
    {
24
        return new MetricsResponse($this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('....'/metrics/usage/data') can also be of type object; however, parameter $metrics 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

24
        return new MetricsResponse(/** @scrutinizer ignore-type */ $this->client->request(
Loading history...
25
            'get',
26
            "/applications/${applicationUuid}/metrics/usage/data"
27
        ));
28
    }
29
30
    /**
31
     * Retrieves aggregate usage metric data for an application.
32
     *
33
     * @return MetricResponse
34
     * @param string $applicationUuid
35
     * @param string $usageMetric
36
     */
37
    public function getAggregateUsageMetrics($applicationUuid, $usageMetric)
38
    {
39
        return new MetricResponse($this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...s/usage/'.$usageMetric) can also be of type array; however, parameter $metric 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

39
        return new MetricResponse(/** @scrutinizer ignore-type */ $this->client->request(
Loading history...
40
            'get',
41
            "/applications/${applicationUuid}/metrics/usage/${usageMetric}"
42
        ));
43
    }
44
45
    /**
46
     * Retrieves usage data for an application, broken down by environment.
47
     *
48
     * @return MetricsResponse
49
     * @param string $applicationUuid
50
     */
51
    public function getDataByEnvironment($applicationUuid)
52
    {
53
        return new MetricsResponse($this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...e/data-by-environment') can also be of type object; however, parameter $metrics 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

53
        return new MetricsResponse(/** @scrutinizer ignore-type */ $this->client->request(
Loading history...
54
            'get',
55
            "/applications/${applicationUuid}/metrics/usage/data-by-environment"
56
        ));
57
    }
58
59
    /**
60
     * Retrieves views data for an application, broken down by environment.
61
     *
62
     * @return MetricsResponse
63
     * @param string $applicationUuid
64
     */
65
    public function getViewsByEnvironment($applicationUuid)
66
    {
67
        return new MetricsResponse($this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('.../views-by-environment') can also be of type object; however, parameter $metrics 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

67
        return new MetricsResponse(/** @scrutinizer ignore-type */ $this->client->request(
Loading history...
68
            'get',
69
            "/applications/${applicationUuid}/metrics/usage/views-by-environment"
70
        ));
71
    }
72
73
    /**
74
     * Retrieves visits data for an application, broken down by environment.
75
     *
76
     * @return MetricsResponse
77
     * @param string $applicationUuid
78
     */
79
    public function getVisitsByEnvironment($applicationUuid)
80
    {
81
        return new MetricsResponse($this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...visits-by-environment') can also be of type object; however, parameter $metrics 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

81
        return new MetricsResponse(/** @scrutinizer ignore-type */ $this->client->request(
Loading history...
82
            'get',
83
            "/applications/${applicationUuid}/metrics/usage/visits-by-environment"
84
        ));
85
    }
86
87
    /**
88
     * Returns StackMetrics data for the metrics specified in the filter paramater
89
     * (e.g., apache-access, web-cpu).
90
     *
91
     * @return MetricsResponse
92
     * @param string $environmentUuid
93
     */
94
    public function getStackMetricsData($environmentUuid)
95
    {
96
        return new MetricsResponse($this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ics/stackmetrics/data') can also be of type object; however, parameter $metrics 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

96
        return new MetricsResponse(/** @scrutinizer ignore-type */ $this->client->request(
Loading history...
97
            'get',
98
            "/environments/${environmentUuid}/metrics/stackmetrics/data"
99
        ));
100
    }
101
102
    /**
103
     * Returns StackMetrics data for the metric (e.g., apache-access).
104
     *
105
     * @return MetricResponse
106
     * @param string $environmentUuid
107
     * @param string $metricType
108
     *
109
     */
110
    public function getStackMetricsDataByMetric($environmentUuid, $metricType)
111
    {
112
        return new MetricResponse($this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...kmetrics/'.$metricType) can also be of type array; however, parameter $metric 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
        return new MetricResponse(/** @scrutinizer ignore-type */ $this->client->request(
Loading history...
113
            'get',
114
            "/environments/${environmentUuid}/metrics/stackmetrics/${metricType}"
115
        ));
116
    }
117
}
118