Completed
Push — master ( 7fdc78...830b42 )
by Jonathan
11s
created

ChangelogConfig::getUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ChangelogGenerator;
6
7
use function sprintf;
8
use function str_replace;
9
use function urlencode;
10
11
class ChangelogConfig
12
{
13
    private const ROOT_URL = 'https://api.github.com';
14
15
    /** @var string */
16
    private $user;
17
18
    /** @var string */
19
    private $repository;
20
21
    /** @var string */
22
    private $milestone;
23
24
    /** @var string[] */
25
    private $labels;
26
27
    /**
28
     * @param string[] $labels
29
     */
30 14
    public function __construct(
31
        string $user,
32
        string $repository,
33
        string $milestone,
34
        array $labels
35
    ) {
36 14
        $this->user       = $user;
37 14
        $this->repository = $repository;
38 14
        $this->milestone  = $milestone;
39 14
        $this->labels     = $labels;
40 14
    }
41
42 1
    public function getUser() : string
43
    {
44 1
        return $this->user;
45
    }
46
47 1
    public function getRepository() : string
48
    {
49 1
        return $this->repository;
50
    }
51
52 2
    public function getMilestone() : string
53
    {
54 2
        return $this->milestone;
55
    }
56
57
    /**
58
     * @return string[]
59
     */
60 2
    public function getLabels() : array
61
    {
62 2
        return $this->labels;
63
    }
64
65 3
    public function getMilestoneIssuesUrl(string $label) : string
66
    {
67 3
        $query = urlencode(sprintf(
68 3
            'milestone:"%s" repo:%s/%s state:closed%s',
69 3
            str_replace('"', '\"', $this->milestone),
70 3
            $this->user,
71 3
            $this->repository,
72 3
            $label !== '' ? ' label:' . $label : ''
73
        ));
74
75 3
        return sprintf('%s/search/issues?q=%s', self::ROOT_URL, $query);
76
    }
77
}
78