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
Pull Request — master (#893)
by Islam
06:18
created

AbstractInterval::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
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
namespace Respect\Validation\Rules;
13
14
use DateTimeImmutable;
15
use Exception;
16
17
abstract class AbstractInterval extends AbstractRule
18
{
19
    public $interval;
20
    public $inclusive;
21
22 16
    public function __construct($interval, $inclusive = true)
23
    {
24 16
        $this->interval = $interval;
25 16
        $this->inclusive = $inclusive;
26 16
    }
27
28 16
    protected function filterInterval($value)
29
    {
30 16
        if (!is_string($value) || is_numeric($value) || empty($value)) {
31 13
            return $value;
32
        }
33
34 11
        if (mb_strlen($value) == 1) {
35 3
            return $value;
36
        }
37
38
        try {
39 9
            return new DateTimeImmutable($value);
40 2
        } catch (Exception $e) {
41
            // Pokémon Exception Handling
42
        }
43
44 2
        return $value;
45
    }
46
}
47