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   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 1
dl 0
loc 30
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
B filterInterval() 0 18 6
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