Total Complexity | 7 |
Total Lines | 23 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class DateValidation extends AbstractValidation implements ValidationInterface |
||
11 | { |
||
12 | 60 | public function isValid(ValueObject $data) |
|
13 | { |
||
14 | 60 | if( ! is_string($data->value()) ) return false; |
|
15 | 54 | if(isset($this->options[0])){ |
|
16 | 11 | $dateObj = DateTime::createFromFormat($this->options[0], $data->value()); |
|
17 | 11 | return $dateObj && $dateObj->format($this->options[0]) === $data->value(); |
|
18 | } |
||
19 | 43 | return strtotime($data->value()) > 0; |
|
20 | } |
||
21 | |||
22 | 35 | protected function afterSuccessValidation() |
|
23 | { |
||
24 | 35 | $this->data->setType(ValueObject::DATE); |
|
25 | 35 | parent::afterSuccessValidation(); |
|
26 | 35 | } |
|
27 | |||
28 | 25 | public function errorMessage() |
|
33 | } |
||
34 | } |