Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( 994665...9b4c4d )
by Henrique
02:39
created

FilterVar::isValidFilter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 1
dl 0
loc 12
ccs 10
cts 10
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Respect\Validation\Rules;
15
16
use Respect\Validation\Exceptions\ComponentException;
17
use const FILTER_VALIDATE_BOOLEAN;
18
use const FILTER_VALIDATE_EMAIL;
19
use const FILTER_VALIDATE_FLOAT;
20
use const FILTER_VALIDATE_INT;
21
use const FILTER_VALIDATE_IP;
22
use const FILTER_VALIDATE_REGEXP;
23
use const FILTER_VALIDATE_URL;
24
25
/**
26
 * Validates the input with the PHP's filter_var() function.
27
 *
28
 * @author Henrique Moody <[email protected]>
29
 */
30
final class FilterVar extends AbstractEnvelope
31
{
32
    private const ALLOWED_FILTERS = [
33
        FILTER_VALIDATE_BOOLEAN,
34
        FILTER_VALIDATE_EMAIL,
35
        FILTER_VALIDATE_FLOAT,
36
        FILTER_VALIDATE_INT,
37
        FILTER_VALIDATE_IP,
38
        FILTER_VALIDATE_REGEXP,
39
        FILTER_VALIDATE_URL,
40
    ];
41
42
    /**
43
     * Initializes the rule.
44
     *
45
     * @param int $filter
46
     * @param mixed $options
47
     *
48
     * @throws ComponentException
49
     */
50 3
    public function __construct(int $filter, $options = null)
51
    {
52 3
        if (!in_array($filter, self::ALLOWED_FILTERS)) {
53 1
            throw new ComponentException('Cannot accept the given filter');
54
        }
55
56 2
        parent::__construct(new Callback('filter_var', $filter, $options), []);
57 2
    }
58
}
59