Path   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 69.23%

Importance

Changes 0
Metric Value
wmc 6
eloc 8
dl 0
loc 33
ccs 9
cts 13
cp 0.6923
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A back() 0 3 1
A __construct() 0 3 1
A isInRoot() 0 3 1
A getSegments() 0 3 1
A stepIn() 0 3 1
A __toString() 0 3 1
1
<?php
2
3
namespace Lneicelis\Transformer\ValueObject;
4
5
class Path
6
{
7
    /** @var string[] */
8
    private $segments;
9
10 19
    public function __construct(array $segments = [])
11
    {
12 19
        $this->segments = $segments;
13 19
    }
14
15
    public function isInRoot(): bool
16
    {
17
        return empty($this->segments);
18
    }
19
20 8
    public function stepIn(string $segment): Path
21
    {
22 8
        return new Path(array_merge($this->segments, [$segment]));
23
    }
24
25
    public function back(): Path
26
    {
27
        return new Path(array_slice($this->segments, 0, count($this->segments) - 1));
28
    }
29
30 9
    public function getSegments(): array
31
    {
32 9
        return $this->segments;
33
    }
34
35 2
    public function __toString()
36
    {
37 2
        return implode('.', $this->segments);
38
    }
39
}
40