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

Logs::download()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Connector\ClientInterface;
6
use AcquiaCloudApi\Response\EnvironmentResponse;
7
use AcquiaCloudApi\Response\EnvironmentsResponse;
8
use AcquiaCloudApi\Response\LogstreamResponse;
9
use AcquiaCloudApi\Response\LogsResponse;
10
use AcquiaCloudApi\Response\OperationResponse;
11
12
/**
13
 * Class Client
14
 * @package AcquiaCloudApi\CloudApi
15
 */
16
class Logs implements CloudApi
17
{
18
19
    /** @var ClientInterface The API client. */
20
    protected $client;
21
22
    /**
23
     * Client constructor.
24
     *
25
     * @param ClientInterface $client
26
     */
27
    public function __construct(ClientInterface $client)
28
    {
29
        $this->client = $client;
30
    }
31
32
    /**
33
     * Returns a list of log files available for download.
34
     *
35
     * @return LogsResponse
36
     */
37
    public function getAll($environmentUuid)
38
    {
39
        return new LogsResponse(
40
            $this->client->request('get', "/environments/${environmentUuid}/logs")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...nvironmentUuid.'/logs') can also be of type Psr\Http\Message\StreamInterface and object; however, parameter $logs 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

40
            /** @scrutinizer ignore-type */ $this->client->request('get', "/environments/${environmentUuid}/logs")
Loading history...
41
        );
42
    }
43
44
    /**
45
     * Downloads a log file.
46
     *
47
     * @return object
48
     */
49
    public function download($environmentUuid, $logType)
50
    {
51
        return new LogsResponse(
52
            $this->client->request('get', "/environments/${environmentUuid}/logs/${logType}")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...Uuid.'/logs/'.$logType) can also be of type Psr\Http\Message\StreamInterface and object; however, parameter $logs 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

52
            /** @scrutinizer ignore-type */ $this->client->request('get', "/environments/${environmentUuid}/logs/${logType}")
Loading history...
53
        );
54
    }
55
56
    /**
57
     * Creates a log file snapshot.
58
     *
59
     * @return OperationResponse
60
     */
61
    public function snapshot($environmentUuid, $logType)
62
    {
63
        return new OperationResponse(
64
            $this->client->request('post', "/environments/${environmentUuid}/logs/${logType}")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...Uuid.'/logs/'.$logType) 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

64
            /** @scrutinizer ignore-type */ $this->client->request('post', "/environments/${environmentUuid}/logs/${logType}")
Loading history...
65
        );
66
    }
67
68
    /**
69
     * Returns logstream WSS stream information.
70
     *
71
     * @return LogstreamResponse
72
     */
73
    public function stream($environmentUuid)
74
    {
75
        return new LogstreamResponse(
76
            $this->client->request('get', "/environments/${environmentUuid}/logstream")
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...nmentUuid.'/logstream') can also be of type array; however, parameter $logstream 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

76
            /** @scrutinizer ignore-type */ $this->client->request('get', "/environments/${environmentUuid}/logstream")
Loading history...
77
        );
78
    }
79
}
80