Passed
Pull Request — master (#34)
by Benjamin
12:13
created

Space::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Kmeans;
4
5
use Kmeans\Interfaces\SpaceInterface;
6
7
class Space implements SpaceInterface
8
{
9
    /**
10
     * @var int<1, max>
11
     */
12
    protected int $dimensions;
13
14
    public function __construct(int $dimensions)
15
    {
16
        if ($dimensions < 1) {
17
            throw new \InvalidArgumentException("Invalid space dimentions: {$dimensions}");
18
        }
19
20
        $this->dimensions = $dimensions;
21
    }
22
23
    public function getDimensions(): int
24
    {
25
        return $this->dimensions;
26
    }
27
28
    public function isEqualTo(SpaceInterface $space): bool
29
    {
30
        return $this->getDimensions() == $space->getDimensions();
31
    }
32
}
33