Assignees::checkAssignee()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
namespace FlexyProject\GitHub\Receiver\Issues;
3
4
/**
5
 * The Trees API class provides access to Issues's assignees.
6
 *
7
 * @link    https://developer.github.com/v3/issues/assignees/
8
 * @package FlexyProject\GitHub\Receiver\Issues
9
 */
10
class Assignees extends AbstractIssues
11
{
12
13
    /**
14
     * List assignees
15
     *
16
     * @link https://developer.github.com/v3/issues/assignees/#list-assignees
17
     * @return array
18
     */
19
    public function listAssignees(): array
20
    {
21
        return $this->getApi()->request($this->getApi()
22
                                             ->sprintf('/repos/:owner/:repo/assignees', $this->getIssues()->getOwner(),
23
                                                 $this->getIssues()->getRepo()));
24
    }
25
26
    /**
27
     * Check assignee
28
     *
29
     * @link  https://developer.github.com/v3/issues/assignees/#check-assignee
30
     *
31
     * @param string $assignee
32
     *
33
     * @return bool
34
     */
35
    public function checkAssignee(string $assignee): bool
36
    {
37
        $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/assignees/:assignee',
38
            $this->getIssues()->getOwner(), $this->getIssues()->getRepo(), $assignee));
39
40
        if ($this->getApi()->getHeaders()['Status'] == '204 No Content') {
41
            return true;
42
        }
43
44
        return false;
45
    }
46
}