| @@ 235-241 (lines=7) @@ | ||
| 232 | ->ifArray()->then(function($v) { |
|
| 233 | $options = 0; |
|
| 234 | foreach ($v as $option) { |
|
| 235 | if (is_numeric($option)) { |
|
| 236 | $options |= (int) $option; |
|
| 237 | } elseif (defined($option)) { |
|
| 238 | $options |= constant($option); |
|
| 239 | } else { |
|
| 240 | throw new InvalidArgumentException('Expected either an integer representing one of the JSON_ constants, or a string of the constant itself.'); |
|
| 241 | } |
|
| 242 | } |
|
| 243 | ||
| 244 | return $options; |
|
| @@ 249-255 (lines=7) @@ | ||
| 246 | ->end() |
|
| 247 | ->beforeNormalization() |
|
| 248 | ->ifString()->then(function($v) { |
|
| 249 | if (is_numeric($v)) { |
|
| 250 | $value = (int) $v; |
|
| 251 | } elseif (defined($v)) { |
|
| 252 | $value = constant($v); |
|
| 253 | } else { |
|
| 254 | throw new InvalidArgumentException('Expected either an integer representing one of the JSON_ constants, or a string of the constant itself.'); |
|
| 255 | } |
|
| 256 | ||
| 257 | return $value; |
|
| 258 | }) |
|