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

Code   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
dl 0
loc 66
rs 10
c 1
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A deploy() 0 15 1
A switch() 0 14 1
A getAll() 0 6 1
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Connector\ClientInterface;
6
use AcquiaCloudApi\Response\BranchesResponse;
7
use AcquiaCloudApi\Response\OperationResponse;
8
9
/**
10
 * Class Code
11
 * @package AcquiaCloudApi\CloudApi
12
 */
13
class Code extends CloudApiBase implements CloudApiInterface
14
{
15
16
    /**
17
     * Shows all code branches and tags in an application.
18
     *
19
     * @param string $applicationUuid
20
     * @return BranchesResponse
21
     */
22
    public function getAll($applicationUuid)
23
    {
24
        return new BranchesResponse(
25
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...pplicationUuid.'/code') can also be of type object; however, parameter $branches 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

25
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
26
                'get',
27
                "/applications/${applicationUuid}/code"
28
            )
29
        );
30
    }
31
    
32
    /**
33
     * Deploys a code branch/tag to an environment.
34
     *
35
     * @param string $environmentUuid
36
     * @param string $branch
37
     * @return OperationResponse
38
     */
39
    public function switch($environmentUuid, $branch)
40
    {
41
42
        $options = [
43
            'form_params' => [
44
                'branch' => $branch,
45
            ],
46
        ];
47
48
        return new OperationResponse(
49
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...ions/switch', $options) 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

49
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
50
                'post',
51
                "/environments/${environmentUuid}/code/actions/switch",
52
                $options
53
            )
54
        );
55
    }
56
57
    /**
58
     * Deploys code from one environment to another environment.
59
     *
60
     * @param string $environmentFromUuid
61
     * @param string $environmentToUuid
62
     * @param string $commitMessage
63
     */
64
    public function deploy($environmentFromUuid, $environmentToUuid, $commitMessage = null)
65
    {
66
67
        $options = [
68
            'form_params' => [
69
                'source' => $environmentFromUuid,
70
                'message' => $commitMessage,
71
            ],
72
        ];
73
74
        return new OperationResponse(
75
            $this->client->request(
0 ignored issues
show
Bug introduced by
It seems like $this->client->request('...Uuid.'/code', $options) 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

75
            /** @scrutinizer ignore-type */ $this->client->request(
Loading history...
76
                'post',
77
                "/environments/${environmentToUuid}/code",
78
                $options
79
            )
80
        );
81
    }
82
}
83