|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Remorhaz\UCD\Exception; |
|
6
|
|
|
|
|
7
|
|
|
use Remorhaz\IntRangeSets\RangeSetInterface; |
|
8
|
|
|
use Throwable; |
|
9
|
|
|
use UnexpectedValueException; |
|
10
|
|
|
|
|
11
|
|
|
use function get_class; |
|
12
|
|
|
use function gettype; |
|
13
|
|
|
use function is_object; |
|
14
|
|
|
|
|
15
|
|
|
final class InvalidPropertyRangeSetException extends UnexpectedValueException implements ExceptionInterface |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @var string |
|
20
|
|
|
*/ |
|
21
|
|
|
private $propertyName; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
private $propertyFile; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var mixed |
|
30
|
|
|
*/ |
|
31
|
|
|
private $rangeSet; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* InvalidPropertyRangeSetException constructor. |
|
35
|
|
|
* |
|
36
|
|
|
* @param string $propertyName |
|
37
|
|
|
* @param string $propertyFile |
|
38
|
|
|
* @param mixed $rangeSet |
|
39
|
|
|
* @param Throwable|null $previous |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct(string $propertyName, string $propertyFile, $rangeSet, Throwable $previous = null) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->propertyName = $propertyName; |
|
44
|
|
|
$this->propertyFile = $propertyFile; |
|
45
|
|
|
$this->rangeSet = $rangeSet; |
|
46
|
|
|
parent::__construct($this->buildMessage(), 0, $previous); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
private function buildMessage(): string |
|
50
|
|
|
{ |
|
51
|
|
|
$actualType = is_object($this->rangeSet) |
|
52
|
|
|
? get_class($this->rangeSet) |
|
53
|
|
|
: gettype($this->rangeSet); |
|
54
|
|
|
$expectedType = RangeSetInterface::class; |
|
55
|
|
|
|
|
56
|
|
|
return |
|
57
|
|
|
"Invalid range set loaded from {$this->propertyFile} for Unicode property '{$this->propertyName}':\n" . |
|
58
|
|
|
"{$actualType} instead of {$expectedType}"; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function getPropertyName(): string |
|
62
|
|
|
{ |
|
63
|
|
|
return $this->propertyName; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function getPropertyFile(): string |
|
67
|
|
|
{ |
|
68
|
|
|
return $this->propertyFile; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return mixed |
|
73
|
|
|
*/ |
|
74
|
|
|
public function getRangeSet() |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->rangeSet; |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|