| @@ 160-166 (lines=7) @@ | ||
| 157 | ->ifArray()->then(function($v) { |
|
| 158 | $options = 0; |
|
| 159 | foreach ($v as $option) { |
|
| 160 | if (is_numeric($option)) { |
|
| 161 | $options |= (int) $option; |
|
| 162 | } elseif (defined($option)) { |
|
| 163 | $options |= constant($option); |
|
| 164 | } else { |
|
| 165 | throw new InvalidArgumentException('Expected either an integer representing one of the JSON_ constants, or a string of the constant itself.'); |
|
| 166 | } |
|
| 167 | } |
|
| 168 | ||
| 169 | return $options; |
|
| @@ 174-180 (lines=7) @@ | ||
| 171 | ->end() |
|
| 172 | ->beforeNormalization() |
|
| 173 | ->ifString()->then(function($v) { |
|
| 174 | if (is_numeric($v)) { |
|
| 175 | $value = (int) $v; |
|
| 176 | } elseif (defined($v)) { |
|
| 177 | $value = constant($v); |
|
| 178 | } else { |
|
| 179 | throw new InvalidArgumentException('Expected either an integer representing one of the JSON_ constants, or a string of the constant itself.'); |
|
| 180 | } |
|
| 181 | ||
| 182 | return $value; |
|
| 183 | }) |
|