|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace JMGQ\AStar\Benchmark\Result; |
|
4
|
|
|
|
|
5
|
|
|
class AggregatedResult |
|
6
|
|
|
{ |
|
7
|
|
|
private int $size; |
|
8
|
|
|
private int $averageDuration; |
|
9
|
|
|
private int $minimumDuration; |
|
10
|
|
|
private int $maximumDuration; |
|
11
|
|
|
private int $numberOfSolutions; |
|
12
|
|
|
private int $numberOfTerrains; |
|
13
|
|
|
|
|
14
|
14 |
|
public function __construct( |
|
15
|
|
|
int $size, |
|
16
|
|
|
int $averageDuration, |
|
17
|
|
|
int $minimumDuration, |
|
18
|
|
|
int $maximumDuration, |
|
19
|
|
|
int $numberOfSolutions, |
|
20
|
|
|
int $numberOfTerrains, |
|
21
|
|
|
) { |
|
22
|
14 |
|
$this->size = $this->filterNaturalNumber($size, 'size'); |
|
23
|
12 |
|
$this->averageDuration = $this->filterNonNegativeInteger($averageDuration, 'average duration'); |
|
24
|
11 |
|
$this->minimumDuration = $this->filterNonNegativeInteger($minimumDuration, 'minimum duration'); |
|
25
|
10 |
|
$this->maximumDuration = $this->filterNonNegativeInteger($maximumDuration, 'maximum duration'); |
|
26
|
9 |
|
$this->numberOfSolutions = $this->filterNonNegativeInteger($numberOfSolutions, 'number of solutions'); |
|
27
|
8 |
|
$this->numberOfTerrains = $this->filterNaturalNumber($numberOfTerrains, 'number of terrains'); |
|
28
|
6 |
|
} |
|
29
|
|
|
|
|
30
|
3 |
|
public function getSize(): int |
|
31
|
|
|
{ |
|
32
|
3 |
|
return $this->size; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
3 |
|
public function getAverageDuration(): int |
|
36
|
|
|
{ |
|
37
|
3 |
|
return $this->averageDuration; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
3 |
|
public function getMinimumDuration(): int |
|
41
|
|
|
{ |
|
42
|
3 |
|
return $this->minimumDuration; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
3 |
|
public function getMaximumDuration(): int |
|
46
|
|
|
{ |
|
47
|
3 |
|
return $this->maximumDuration; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
3 |
|
public function getNumberOfSolutions(): int |
|
51
|
|
|
{ |
|
52
|
3 |
|
return $this->numberOfSolutions; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
3 |
|
public function getNumberOfTerrains(): int |
|
56
|
|
|
{ |
|
57
|
3 |
|
return $this->numberOfTerrains; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
14 |
|
private function filterNaturalNumber(int $value, string $parameterName): int |
|
61
|
|
|
{ |
|
62
|
14 |
|
if ($value < 1) { |
|
63
|
4 |
|
throw new \InvalidArgumentException("Invalid $parameterName: $value"); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
12 |
|
return $value; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
12 |
|
private function filterNonNegativeInteger(int $value, string $parameterName): int |
|
70
|
|
|
{ |
|
71
|
12 |
|
if ($value < 0) { |
|
72
|
4 |
|
throw new \InvalidArgumentException("Invalid $parameterName: $value"); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
11 |
|
return $value; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|