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