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

Path::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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