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

Space::getDimensions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
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