for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Install GitHub App
<?php
/*
* This file is part of Respect/Validation.
*
* (c) Alexandre Gomes Gaigalas <[email protected]>
* For the full copyright and license information, please view the "LICENSE.md"
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Rules;
use Respect\Validation\Exceptions\ComponentException;
use const FILTER_VALIDATE_BOOLEAN;
use const FILTER_VALIDATE_EMAIL;
use const FILTER_VALIDATE_FLOAT;
use const FILTER_VALIDATE_INT;
use const FILTER_VALIDATE_IP;
use const FILTER_VALIDATE_REGEXP;
use const FILTER_VALIDATE_URL;
/**
* Validates the input with the PHP's filter_var() function.
* @author Henrique Moody <[email protected]>
final class FilterVar extends AbstractEnvelope
{
private const ALLOWED_FILTERS = [
FILTER_VALIDATE_BOOLEAN,
FILTER_VALIDATE_EMAIL,
FILTER_VALIDATE_FLOAT,
FILTER_VALIDATE_INT,
FILTER_VALIDATE_IP,
FILTER_VALIDATE_REGEXP,
FILTER_VALIDATE_URL,
];
* Initializes the rule.
* @param int $filter
* @param mixed $options
* @throws ComponentException
public function __construct(int $filter, $options = null)
if (!in_array($filter, self::ALLOWED_FILTERS)) {
throw new ComponentException('Cannot accept the given filter');
}
parent::__construct(new Callback('filter_var', $filter, $options), []);