DateValidator::__invoke()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 5
nc 2
nop 1
crap 4
1
<?php
2
namespace PTS\Validator\Validators;
3
4
class DateValidator
5
{
6 6
    public function __invoke($value): bool
7
    {
8 6
        if ((!\is_string($value) && !\is_numeric($value)) || strtotime($value) === false) {
9 1
            return false;
10
        }
11
        
12 5
        $date = date_parse($value);
13 5
        return checkdate($date['month'], $date['day'], $date['year']);
14
    }
15
}
16