Passed
Pull Request — master (#34)
by Benjamin
26:50 queued 11:50
created

Space::singleton()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace Kmeans\Gps;
4
5
use Kmeans\Interfaces\PointInterface;
6
use Kmeans\Interfaces\SpaceInterface;
7
8
class Space implements SpaceInterface
9
{
10
    public static function singleton(): self
11
    {
12
        static $space = new self();
13
14
        return $space;
15
    }
16
17
    public function isEqualTo(SpaceInterface $other): bool
18
    {
19
        return $other instanceof self;
20
    }
21
22
    /**
23
     * @param array{0: float, 1: float} $coordinates
24
     */
25
    public function makePoint(array $coordinates): PointInterface
26
    {
27
        return new Point(...$coordinates);
28
    }
29
}
30