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 $bigintMode = 0; |
||
26 | |||
27 | /** |
||
28 | * @param int $bigintMode |
||
29 | */ |
||
30 | 50 | public function __construct($bigintMode = self::BIGINT_MODE_STRING_INVALID) |
|
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | 50 | public function validate($value, $type, Validator $validator) |
|
87 | |||
88 | /** |
||
89 | * @param int $bigintMode |
||
90 | * |
||
91 | * @throws \InvalidArgumentException |
||
92 | */ |
||
93 | public function setBigintMode($bigintMode = self::BIGINT_MODE_STRING_INVALID) |
||
101 | |||
102 | /** |
||
103 | * @return int |
||
104 | */ |
||
105 | public function getBigintMode() |
||
109 | |||
110 | /** |
||
111 | * @param mixed $value |
||
112 | * @param callable $callable |
||
113 | * @param \League\JsonGuard\Validator $validator |
||
114 | * |
||
115 | * @return \League\JsonGuard\ValidationError|null |
||
116 | * |
||
117 | */ |
||
118 | 48 | private function validateType($value, callable $callable, Validator $validator) |
|
126 | |||
127 | /** |
||
128 | * @param mixed $value |
||
129 | * @param array $choices |
||
130 | * |
||
131 | * @param Validator $validator |
||
132 | * |
||
133 | * @return ValidationError|null |
||
134 | */ |
||
135 | 4 | private function anyType($value, array $choices, Validator $validator) |
|
146 | } |
||
147 |