DateTimeTransformer::transform()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 3
nc 3
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