At::offsetExists()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Pathfinder\Graph;
4
5
use BadMethodCallException;
6
use Stratadox\Pathfinder\Position;
7
8
final class At implements Position
9
{
10
    private $coordinates;
11
12
    private function __construct(float ...$coordinates)
13
    {
14
        $this->coordinates = $coordinates;
15
    }
16
17
    public static function position(float ...$coordinates): Position
18
    {
19
        return new self(...$coordinates);
20
    }
21
22
    public function offsetExists($offset): bool
23
    {
24
        return true;
25
    }
26
27
    public function offsetGet($offset): float
28
    {
29
        return $this->coordinates[$offset] ?? 0.0;
30
    }
31
32
    public function offsetSet($offset, $value): void
33
    {
34
        throw new BadMethodCallException('Unsupported operation.');
35
    }
36
37
    public function offsetUnset($offset): void
38
    {
39
        throw new BadMethodCallException('Unsupported operation.');
40
    }
41
}
42