Test Failed
Push — master ( 45fe2f...125557 )
by Jinyun
02:31
created

NumberOfDaysInAMonth::numberOfDays()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 8
rs 10
cc 4
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace leetcode;
6
7
class NumberOfDaysInAMonth
8
{
9
    public static function numberOfDays(int $year, int $month): int
10
    {
11
        $days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
12
        if (($year % 4 === 0 && $year % 100 !== 0) || $year % 400 === 0) {
13
            $days[1] += 1;
14
        }
15
16
        return $days[$month - 1];
17
    }
18
}
19