Test Failed
Branch develop (09cda0)
by Samson
03:06
created

LeapYearValidator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A isValid() 0 6 2
A isValidLeapYear() 0 4 1
1
<?php
2
3
namespace Andegna\Validator;
4
5
class LeapYearValidator implements Validator
6
{
7
    use ValidIntegerValidator;
8
9
    private $year;
10
11
    public function __construct($year)
12
    {
13
        $this->year = $year;
14
    }
15
16
    public function isValid()
17
    {
18
        return
19
            $this->isValidInteger($this->year) &&
20
            $this->isValidLeapYear($this->year);
21
    }
22
23
    protected function isValidLeapYear($year)
24
    {
25
        return ($year + 1) % 4 === 0;
26
    }
27
}
28