At   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 8
c 1
b 0
f 0
dl 0
loc 32
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetExists() 0 3 1
A position() 0 3 1
A offsetGet() 0 3 1
A offsetSet() 0 3 1
A __construct() 0 3 1
A offsetUnset() 0 3 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