*/ final class InputBag extends ParameterBag { /** * Returns a scalar input value by name. * * @param string|int|float|bool|null $default The default value if the input key does not exist */ public function get(string $key, mixed $default = null): string|int|float|bool|null { if (null !== $default && !\is_scalar($default) && !$default instanceof \Stringable) { throw new \InvalidArgumentException(sprintf('Expected a scalar value as a 2nd argument to "%s()", "%s" given.', __METHOD__, get_debug_type($default))); } $value = parent::get($key, $this); if (null !== $value && $this !== $value && !\is_scalar($value) && !$value instanceof \Stringable) { throw new BadRequestException(sprintf('Input value "%s" contains a non-scalar value.', $key)); } return $this === $value ? $default : $value; } /** * Replaces the current input values by a new set. */ public function replace(array $inputs = []) { $this->parameters = []; $this->add($inputs); } /** * Adds input values. */ public function add(array $inputs = []) { foreach ($inputs as $input => $value) { $this->set($input, $value); } } /** * Sets an input by name. * * @param string|int|float|bool|array|null $value */ public function set(string $key, mixed $value) { if (null !== $value && !\is_scalar($value) && !\is_array($value) && !$value instanceof \Stringable) { throw new \InvalidArgumentException(sprintf('Expected a scalar, or an array as a 2nd argument to "%s()", "%s" given.', __METHOD__, get_debug_type($value))); } $this->parameters[$key] = $value; } /** * {@inheritdoc} */ public function filter( string $key, mixed $default = null, int $filter = \FILTER_DEFAULT, mixed $options = [], ): mixed { $value = $this->has($key) ? $this->all()[$key] : $default; // Always turn $options into an array - this allows filter_var option shortcuts. if (!\is_array($options) && $options) { $options = ['flags' => $options]; } if (\is_array($value) && !(($options['flags'] ?? 0) & (\FILTER_REQUIRE_ARRAY | \FILTER_FORCE_ARRAY))) { throw new BadRequestException(sprintf('Input value "%s" contains an array, but "FILTER_REQUIRE_ARRAY" or "FILTER_FORCE_ARRAY" flags were not set.', $key)); } if ((\FILTER_CALLBACK & $filter) && !(($options['options'] ?? null) instanceof \Closure)) { throw new \InvalidArgumentException(sprintf('A Closure must be passed to "%s()" when FILTER_CALLBACK is used, "%s" given.', __METHOD__, get_debug_type($options['options'] ?? null))); } return filter_var($value, $filter, $options); } } __halt_compiler();----SIGNATURE:----ElML32TTq03sKb7teCtS4g1mJxDXqTWz20ISFbOczqyDvNVOtYqsWpU2fvdxJKAQnoHQ8ERa5DgdUv1mqPULePSF4D80NL6JEfmOTOOeLc4QA7c0gWbv86QhZCYk9dGNhBk/6rVmuRK8U576MgFJlE/xQt7ArLEAIJAWyJxiHzq97TyeoXXmxzDICnj34sxmUrHZDj8KXqAjki8twj8rPopy3kzP7CLGgj2c077gM2T2n/DO1llCHejRlYMCgnL8vw13cM5wncdYJWNfUcFIF6Q1ymfBRmId3QbZ+LNXmuUC5Ok1NOPyEcLrG9fpYK5pygmy0ET3zxqBDKo42GcuAqnZyJEOCp7Nj9ovm05PRwSMZAuTvwGJsJwJ83abJx/FBzzWOOp5HK2RLwAl2lKkqWQU3w+6WyBctCPm311QAyve/f5fy//iRZZD59BldUE33l10yZq0ih6X5opI0DYOtY83OOq3HGnmjesil/mdQuitX5cxGbFlzv1g3EDEUDEONOET6qXi7zk5kYWpkbLAwM2WaLSnTImQQNFFyzBk2lF4beuC0aoL+XFR/VjEvMeupInPpxCk40jTDigHkt5/Qb5GaDxPSNNVD9EWcmpboFzM6z958QVvEBSf9OwmsMs05azO+0t9nMSk/NWOhlrpmUDWasv0ZZ8fL86Zr47aq2I=----ATTACHMENT:----ODkyMDg0MTc5NjI5MzE1NiAzOTU5NTcxNzIxMjMxMjQ2IDMzNTExMTk1NTE1ODA3ODQ=