Passed
Push — master ( 5cce8c...cb0ced )
by Edward
04:53
created

Path   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 28
ccs 11
cts 11
cp 1
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A copyWithProperty() 0 3 1
A getElements() 0 3 1
A equals() 0 3 1
A __construct() 0 3 1
A copyWithElement() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Remorhaz\JSON\Data\Path;
5
6
final class Path implements PathInterface
7
{
8
9
    private $elements;
10
11 9
    public function __construct(...$elements)
12
    {
13 9
        $this->elements = $elements;
14 9
    }
15
16 2
    public function copyWithElement(int $index): PathInterface
17
    {
18 2
        return new self(...$this->elements, ...[$index]);
19
    }
20
21 2
    public function copyWithProperty(string $name): PathInterface
22
    {
23 2
        return new self(...$this->elements, ...[$name]);
24
    }
25
26 7
    public function getElements(): array
27
    {
28 7
        return $this->elements;
29
    }
30
31 4
    public function equals(PathInterface $path): bool
32
    {
33 4
        return $path->getElements() == $this->elements;
34
    }
35
}
36