Statuses::listStatuses()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
namespace FlexyProject\GitHub\Receiver\Repositories;
3
4
use Symfony\Component\HttpFoundation\Request;
5
6
/**
7
 * The Statuses API class provides access to repository's statuses.
8
 *
9
 * @link    https://developer.github.com/v3/repos/statuses/
10
 * @package FlexyProject\GitHub\Receiver\Repositories
11
 */
12
class Statuses extends AbstractRepositories
13
{
14
15
    /**
16
     * Create a Status
17
     *
18
     * @link https://developer.github.com/v3/repos/statuses/#create-a-status
19
     *
20
     * @param string $sha
21
     * @param string $state
22
     * @param string $targetUrl
23
     * @param string $description
24
     * @param string $context
25
     *
26
     * @return array
27
     */
28 View Code Duplication
    public function createStatus(string $sha, string $state, string $targetUrl = null, string $description = null,
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
                                 string $context = 'default'): array
30
    {
31
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/statuses/:sha',
32
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $sha), Request::METHOD_POST, [
33
                'state'       => $state,
34
                'target_url'  => $targetUrl,
35
                'description' => $description,
36
                'context'     => $context
37
            ]);
38
    }
39
40
    /**
41
     * List Statuses for a specific Ref
42
     *
43
     * @link https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref
44
     *
45
     * @param string $ref
46
     *
47
     * @return array
48
     */
49
    public function listStatuses(string $ref): array
50
    {
51
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/commits/:ref/statuses',
52
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $ref));
53
    }
54
55
    /**
56
     * Get the combined Status for a specific Ref
57
     *
58
     * @link https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
59
     *
60
     * @param string $ref
61
     *
62
     * @return array
63
     */
64
    public function getCombinedStatus(string $ref): array
65
    {
66
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/commits/:ref/status',
67
            $this->getRepositories()->getOwner(), $this->getRepositories()->getRepo(), $ref));
68
    }
69
}