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   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
c 0
b 0
f 0
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 16 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