Completed
Push — master ( 0e8f56...28a10f )
by Alexpts
02:22
created

DateValidator::__invoke()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

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