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 — 0.9 (#692)
by
unknown
02:58
created

LeapYear::validate()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
ccs 11
cts 11
cp 1
rs 9.2
cc 4
eloc 11
nc 4
nop 1
crap 4
1
<?php
2
namespace Respect\Validation\Rules;
3
4
use DateTime;
5
6
class LeapYear extends AbstractRule
7
{
8 2
    public function validate($year)
9
    {
10 2
        if (is_numeric($year)) {
11 2
            $year = (int) $year;
12 2
        } elseif (is_string($year)) {
13 2
            $year = (int) date('Y', strtotime($year));
14 2
        } elseif ($year instanceof DateTime) {
15 2
            $year = (int) $year->format('Y');
16 2
        } else {
17 1
            return false;
18
        }
19
20 2
        $date = strtotime(sprintf('%d-02-29', $year));
21
22 2
        return (bool) date('L', $date);
23
    }
24
}
25