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 ( 2d7e2e...fe3654 )
by Henrique
02:51
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
declare(strict_types=1);
13
14
namespace Respect\Validation\Rules;
15
16
use DateTimeImmutable;
17
use Exception;
18
19
abstract class AbstractInterval extends AbstractRule
20
{
21
    public $interval;
22
    public $inclusive;
23
24 16
    public function __construct($interval, $inclusive = true)
25
    {
26 16
        $this->interval = $interval;
27 16
        $this->inclusive = $inclusive;
28 16
    }
29
30 16
    protected function filterInterval($value)
31
    {
32 16
        if (!is_string($value) || is_numeric($value) || empty($value)) {
33 13
            return $value;
34
        }
35
36 11
        if (1 == mb_strlen($value)) {
37 3
            return $value;
38
        }
39
40
        try {
41 9
            return new DateTimeImmutable($value);
42 2
        } catch (Exception $e) {
43
            // Pokémon Exception Handling
44
        }
45
46 2
        return $value;
47
    }
48
}
49