1 | <?php |
||
11 | final class Type implements ConstraintInterface |
||
12 | { |
||
13 | const KEYWORD = 'type'; |
||
14 | |||
15 | /** |
||
16 | * Whether examples like 98249283749234923498293171823948729348710298301928331 |
||
17 | * and "98249283749234923498293171823948729348710298301928331" are valid strings. |
||
18 | */ |
||
19 | const BIGINT_MODE_STRING_VALID = 1; |
||
20 | const BIGINT_MODE_STRING_INVALID = 2; |
||
21 | |||
22 | /** |
||
23 | * @var int |
||
24 | */ |
||
25 | private static $defaultBigintMode = self::BIGINT_MODE_STRING_INVALID; |
||
26 | |||
27 | /** |
||
28 | * @var int |
||
29 | */ |
||
30 | private $bigintMode = 0; |
||
31 | |||
32 | /** |
||
33 | * @param int $bigintMode |
||
34 | */ |
||
35 | 58 | public function __construct($bigintMode = null) |
|
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | 58 | public function validate($value, $type, Validator $validator) |
|
92 | |||
93 | /** |
||
94 | * @param int|null $bigintMode |
||
95 | * |
||
96 | * @throws \InvalidArgumentException |
||
97 | */ |
||
98 | public function setBigintMode($bigintMode = null) |
||
106 | |||
107 | /** |
||
108 | * @return int |
||
109 | */ |
||
110 | public function getBigintMode() |
||
114 | |||
115 | /** |
||
116 | * @param int $defaultBigintMode |
||
117 | * |
||
118 | * @throws \InvalidArgumentException |
||
119 | */ |
||
120 | 4 | public static function setDefaultBigintMode($defaultBigintMode) |
|
128 | |||
129 | /** |
||
130 | * @return int |
||
131 | */ |
||
132 | 4 | public static function getDefaultBigintMode() |
|
136 | |||
137 | /** |
||
138 | * @param mixed $value |
||
139 | * @param callable $callable |
||
140 | * @param \League\JsonGuard\Validator $validator |
||
141 | * |
||
142 | * @return \League\JsonGuard\ValidationError|null |
||
143 | * |
||
144 | */ |
||
145 | 56 | private function validateType($value, callable $callable, Validator $validator) |
|
153 | |||
154 | /** |
||
155 | * @param mixed $value |
||
156 | * @param array $choices |
||
157 | * |
||
158 | * @param Validator $validator |
||
159 | * |
||
160 | * @return ValidationError|null |
||
161 | */ |
||
162 | 4 | private function anyType($value, array $choices, Validator $validator) |
|
173 | } |
||
174 |