| @@ 138-144 (lines=7) @@ | ||
| 135 | ->ifArray()->then(function($v) { |
|
| 136 | $options = 0; |
|
| 137 | foreach ($v as $option) { |
|
| 138 | if (is_numeric($option)) { |
|
| 139 | $options |= (int) $option; |
|
| 140 | } elseif (defined($option)) { |
|
| 141 | $options |= constant($option); |
|
| 142 | } else { |
|
| 143 | throw new InvalidArgumentException('Expected either an integer representing one of the JSON_ constants, or a string of the constant itself.'); |
|
| 144 | } |
|
| 145 | } |
|
| 146 | ||
| 147 | return $options; |
|
| @@ 152-158 (lines=7) @@ | ||
| 149 | ->end() |
|
| 150 | ->beforeNormalization() |
|
| 151 | ->ifString()->then(function($v) { |
|
| 152 | if (is_numeric($v)) { |
|
| 153 | $value = (int) $v; |
|
| 154 | } elseif (defined($v)) { |
|
| 155 | $value = constant($v); |
|
| 156 | } else { |
|
| 157 | throw new InvalidArgumentException('Expected either an integer representing one of the JSON_ constants, or a string of the constant itself.'); |
|
| 158 | } |
|
| 159 | ||
| 160 | return $value; |
|
| 161 | }) |
|