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   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 23
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A validate() 0 13 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