Completed
Push — master ( 8ce34a...26baa3 )
by Marcus
03:49
created

Year::__invoke()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 10
loc 10
ccs 5
cts 5
cp 1
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 2
crap 3
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 View Code Duplication
class Year implements ValidateRuleInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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