Passed
Branch reduce-soap-envelope-builder-c... (f028c1)
by Rait
07:42
created

StrAsServiceReference   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 45
ccs 17
cts 17
cp 1
rs 10
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A memberCode() 0 3 1
A serviceVersion() 0 3 1
A serviceCode() 0 3 1
A xRoadInstance() 0 3 1
A memberClass() 0 3 1
A __construct() 0 8 2
A subSystemCode() 0 3 1
1
<?php
2
3
namespace Raigu\XRoad\SoapEnvelope;
4
5
final class StrAsServiceReference implements XRoadMember, XRoadService
6
{
7
    /**
8
     * @var array
9
     */
10
    private $parts;
11
12 1
    public function xRoadInstance(): string
13
    {
14 1
        return $this->parts[0];
15
    }
16
17 1
    public function memberClass(): string
18
    {
19 1
        return $this->parts[1];
20
    }
21
22 1
    public function memberCode(): string
23
    {
24 1
        return $this->parts[2];
25
    }
26
27 1
    public function subSystemCode(): string
28
    {
29 1
        return $this->parts[3];
30
    }
31
32 1
    public function serviceCode(): string
33
    {
34 1
        return $this->parts[4];
35
    }
36
37 1
    public function serviceVersion(): string
38
    {
39 1
        return $this->parts[5];
40
    }
41
42 2
    public function __construct(string $reference)
43
    {
44 2
        $parts = explode('/', $reference);
45 2
        if (count($parts) !== 6) {
46 1
            throw new \Exception('Could not extract service parameters. Invalid format.');
47
        }
48
49 1
        return $this->parts = $parts;
50
    }
51
52
}
53