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 (#875)
by
unknown
02:51
created

Date::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
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 DateTimeInterface;
15
16
class Date extends AbstractRule
17
{
18
    public $format = null;
19
20 27
    public function __construct($format = null)
21
    {
22 27
        $this->format = $format;
23 27
    }
24
25 27
    public function validate($input)
26
    {
27 27
        var_dump($input);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($input); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
28 27
        if ($input instanceof DateTimeInterface) {
29 2
            return true;
30
        }
31
32 25
        if (!is_scalar($input)) {
33 1
            return false;
34
        }
35
36 24
        $allowedFormat = '/[djSFmMnYy\W]+$/';
37 24
        if(!preg_match($allowedFormat, $this->format)) {
38 20
            return false;
39
        }
40
41 4
        $inputString = (string) $input;
42 4
        if (is_null($this->format)) {
43
            return false !== strtotime($inputString);
44
        }
45
46 4
        $info = date_parse_from_format($this->format, $inputString);
47
48 4
        return $info['error_count'] === 0 && $info['warning_count'] === 0;
49
    }
50
}
51