Completed
Pull Request — master (#34)
by Adam
03:25
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\OperationResponse;
9
10
/**
11
 * Class Client
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class Insights implements CloudApi
15
{
16
17
    /** @var ClientInterface The API client. */
18
    protected $client;
19
20
    /**
21
     * Client constructor.
22
     *
23
     * @param ClientInterface $client
24
     */
25
    public function __construct(ClientInterface $client)
26
    {
27
        $this->client = $client;
28
    }
29
30
    /**
31
     * Returns Insight data for all sites associated with the application by its UUID.
32
     *
33
     * @param string $applicationUuid
34
     * @return InsightsResponse
35
     */
36
    public function getAll($applicationUuid)
37
    {
38
        return new InsightsResponse(
39
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...icationUuid.'/insight') can also be of type Psr\Http\Message\StreamInterface and 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

39
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
40
                'get',
41
                "/applications/${applicationUuid}/insight"
42
            )
43
        );
44
    }
45
46
    /**
47
     * Returns insight data for a particular site.
48
     *
49
     * @param string $siteId
50
     * @return InsightResponse
51
     */
52
    public function get($siteId)
53
    {
54
        return new InsightResponse(
55
            $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

55
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
56
                'get',
57
                "/insight/${siteId}"
58
            )
59
        );
60
    }
61
}
62