Result   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
eloc 16
c 0
b 0
f 0
dl 0
loc 44
ccs 19
cts 19
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A hasSolution() 0 3 1
A filterSize() 0 7 2
A getDuration() 0 3 1
A filterDuration() 0 7 2
A getSize() 0 3 1
1
<?php
2
3
namespace JMGQ\AStar\Benchmark\Result;
4
5
class Result
6
{
7
    private int $size;
8
    private int $duration;
9
    private bool $hasSolution;
10
11 9
    public function __construct(int $size, int $duration, bool $hasSolution)
12
    {
13 9
        $this->size = $this->filterSize($size);
14 7
        $this->duration = $this->filterDuration($duration);
15 6
        $this->hasSolution = $hasSolution;
16 6
    }
17
18 4
    public function getSize(): int
19
    {
20 4
        return $this->size;
21
    }
22
23 4
    public function getDuration(): int
24
    {
25 4
        return $this->duration;
26
    }
27
28 5
    public function hasSolution(): bool
29
    {
30 5
        return $this->hasSolution;
31
    }
32
33 9
    private function filterSize(int $size): int
34
    {
35 9
        if ($size < 1) {
36 2
            throw new \InvalidArgumentException("Invalid size: $size");
37
        }
38
39 7
        return $size;
40
    }
41
42 7
    private function filterDuration(int $duration): int
43
    {
44 7
        if ($duration < 0) {
45 1
            throw new \InvalidArgumentException("Invalid duration: $duration");
46
        }
47
48 6
        return $duration;
49
    }
50
}
51