Completed
Pull Request — master (#61)
by Michal
02:16
created

EndpointIdentifier   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 94.44%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 46
ccs 17
cts 18
cp 0.9444
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getMethod() 0 4 1
A getVersion() 0 4 1
A getPackage() 0 4 1
A getUrl() 0 4 1
A getApiAction() 0 7 2
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