Completed
Pull Request — master (#30)
by
unknown
01:34
created

DateTimeTransformer::throwInvalidConstraintExceptionForDateTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Linio\Component\Input\Transformer;
6
7
class DateTimeTransformer implements TransformerInterface
8
{
9
    public function transform($value)
10
    {
11
        if ($value === null) {
12
            return;
13
        }
14
15
        try {
16
            $date = new \DateTime($value);
17
        } catch (\Exception $e) {
18
            return;
19
        }
20
21
        return $date;
22
    }
23
}
24