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

LeapYear   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 16 4
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 LeapYear extends AbstractRule
17
{
18 2
    public function validate($year)
19
    {
20 2
        if (is_numeric($year)) {
21 2
            $year = (int) $year;
22 2
        } elseif (is_string($year)) {
23 2
            $year = (int) date('Y', strtotime($year));
24 2
        } elseif ($year instanceof DateTime) {
25 2
            $year = (int) $year->format('Y');
26
        } else {
27 1
            return false;
28
        }
29
30 2
        $date = strtotime(sprintf('%d-02-29', $year));
31
32 2
        return (bool) date('L', $date);
33
    }
34
}
35