Total Complexity | 5 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | class DatetimeGuesser extends AbstractGuesser implements GuesserInterface |
||
6 | { |
||
7 | public function supports(array $mapping) |
||
8 | { |
||
9 | $mapping = array_merge([ 'type' => null ], $mapping); |
||
10 | |||
11 | return in_array($mapping['type'], ['datetime', 'date', 'time']); |
||
12 | } |
||
13 | |||
14 | public function transform($str, array $mapping = null) |
||
15 | { |
||
16 | try { |
||
17 | return new \DateTime($str); |
||
18 | } catch (\Exception $e) { |
||
19 | throw new \Exception(sprintf('"%s" is not a supported date/time/datetime format. To know which formats are supported, please visit http://www.php.net/manual/en/datetime.formats.php', $str)); |
||
20 | } |
||
21 | } |
||
22 | |||
23 | public function fake(array $mapping) |
||
26 | } |
||
27 | |||
28 | public function getName() |
||
31 | } |
||
32 | } |
||
33 |