Completed
Pull Request — master (#61)
by Michal
02:56 queued 40s
created

EndpointIdentifier::getUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Tomaj\NetteApi;
4
5
class EndpointIdentifier implements EndpointInterface
6
{
7
    private $method;
8
9
    private $version;
10
11
    private $package;
12
13
    private $apiAction;
14
15 45
    public function __construct(string $method, int $version, string $package, ?string $apiAction = null)
16
    {
17 45
        $this->method = strtoupper($method);
18 45
        $this->version = $version;
19 45
        $this->package = $package;
20 45
        $this->apiAction = $apiAction;
21 45
    }
22
23 27
    public function getMethod(): string
24
    {
25 27
        return $this->method;
26
    }
27
28 30
    public function getVersion(): int
29
    {
30 30
        return $this->version;
31
    }
32
33 30
    public function getPackage(): string
34
    {
35 30
        return $this->package;
36
    }
37
38 33
    public function getApiAction(): ?string
39
    {
40 33
        if ($this->apiAction === '') {
41
            return null;
42
        }
43 33
        return $this->apiAction;
44
    }
45
46 3
    public function getUrl(): string
47
    {
48 3
        return "v{$this->version}/{$this->package}/{$this->apiAction}";
49
    }
50
}
51