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 — 1.1 (#1060)
by Henrique
03:09
created

AbstractInterval   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 1
dl 0
loc 35
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isAbleToCompareValues() 0 4 1
A 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 DateTime;
15
use Exception;
16
17
abstract class AbstractInterval extends AbstractRule
18
{
19
    public $interval;
20
    public $inclusive;
21
22
    public function __construct($interval, $inclusive = true)
23
    {
24
        $this->interval = $interval;
25
        $this->inclusive = $inclusive;
26
    }
27
28
    protected function isAbleToCompareValues($left, $right)
29
    {
30
        return is_scalar($left) === is_scalar($right);
31
    }
32
33
    protected function filterInterval($value)
34
    {
35
        if (!is_string($value) || is_numeric($value) || empty($value)) {
36
            return $value;
37
        }
38
39
        if (strlen($value) == 1) {
40
            return $value;
41
        }
42
43
        try {
44
            return new DateTime($value);
45
        } catch (Exception $e) {
46
            // Pokémon Exception Handling
47
        }
48
49
        return $value;
50
    }
51
}
52