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 (#825)
by Wouter
03:35
created

LeapDate::validate()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 8
nc 3
nop 1
crap 3
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
16
class LeapDate extends AbstractRule
17
{
18
    public $format = null;
19
20 5
    public function __construct($format)
21
    {
22 5
        $this->format = $format;
23 5
    }
24
25 5
    public function validate($input)
26
    {
27 5
        if (is_string($input)) {
28 2
            $date = DateTime::createFromFormat($this->format, $input);
29 3
        } elseif ($input instanceof DateTime) {
30 2
            $date = $input;
31
        } else {
32 1
            return false;
33
        }
34
35
        // Dates that aren't leap will aways be rounded
36 4
        return $date->format('m-d') == '02-29';
37
    }
38
}
39