1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OpenConext\Value\Exception; |
4
|
|
|
|
5
|
|
|
use OutOfBoundsException; |
6
|
|
|
|
7
|
|
|
final class IndexOutOfBoundsException extends OutOfBoundsException implements OpenConextValueException |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @var int |
11
|
|
|
*/ |
12
|
|
|
private $invalidIndex; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var int|null |
16
|
|
|
*/ |
17
|
|
|
private $minimumIndex; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var int|null |
21
|
|
|
*/ |
22
|
|
|
private $maximumIndex; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param int $invalidIndex |
26
|
|
|
* @param int $minimumIndex |
27
|
|
|
* @return IndexOutOfBoundsException |
28
|
|
|
*/ |
29
|
|
|
public static function tooLow($invalidIndex, $minimumIndex) |
30
|
|
|
{ |
31
|
|
|
$message = sprintf('Index "%d" is lower than the minimum index "%d"', $invalidIndex, $minimumIndex); |
32
|
|
|
|
33
|
|
|
$exception = new self($message); |
34
|
|
|
$exception->invalidIndex = $invalidIndex; |
35
|
|
|
$exception->minimumIndex = $minimumIndex; |
36
|
|
|
|
37
|
|
|
return $exception; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param int $invalidIndex |
42
|
|
|
* @param int $maximumIndex |
43
|
|
|
* @return IndexOutOfBoundsException |
44
|
|
|
*/ |
45
|
|
|
public static function tooHigh($invalidIndex, $maximumIndex) |
46
|
|
|
{ |
47
|
|
|
$message = sprintf('Index "%d" is higher than the maximum index "%d"', $invalidIndex, $maximumIndex); |
48
|
|
|
|
49
|
|
|
$exception = new self($message); |
50
|
|
|
$exception->invalidIndex = $invalidIndex; |
51
|
|
|
$exception->maximumIndex = $maximumIndex; |
52
|
|
|
|
53
|
|
|
return $exception; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return int |
58
|
|
|
*/ |
59
|
|
|
public function getInvalidIndex() |
60
|
|
|
{ |
61
|
|
|
return $this->invalidIndex; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return int|null |
66
|
|
|
*/ |
67
|
|
|
public function getMinimumIndex() |
68
|
|
|
{ |
69
|
|
|
return $this->minimumIndex; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return int|null |
74
|
|
|
*/ |
75
|
|
|
public function getMaximumIndex() |
76
|
|
|
{ |
77
|
|
|
return $this->maximumIndex; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|