Year::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 2
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Mbright\Validation\Rule\Validate\MySql;
4
5
use Mbright\Validation\Rule\Validate\ValidateRuleInterface;
6
7
/**
8
 * Handles 4 digit years supported by mysql 8.0
9
 */
10
class Year implements ValidateRuleInterface
11
{
12 21
    public function __invoke($subject, string $field): bool
13
    {
14 21
        $value = $subject->$field;
15
16 21
        if (!is_int($value)) {
17 6
            return false;
18
        }
19
20 15
        return $value >= 1901 && $value <= 2155;
21
    }
22
}
23