Completed
Push — master ( 8c9293...cb7237 )
by Tomasz
05:09
created

Date   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 15
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMessage() 0 6 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Hop\Validator\Validator;
6
7
/**
8
 * Class Date
9
 * @package Hop\Validator\Validator
10
 */
11
final class Date implements RuleValidator
12
{
13
    use IsValidTrait;
14
15
    /**
16
     * @param mixed $value
17
     * @param array|null $options
18
     * @return null|string
19
     */
20 2
    public function getMessage($value, ?array $options)
21
    {
22 2
        if (!\preg_match('/^\d{4}\-\d{2}\-\d{2}$/', (string)$value)) {
23 1
            return 'Value is not a date';
24
        }
25 1
        return null;
26
    }
27
}
28