| @@ 80-91 (lines=12) @@ | ||
| 77 | * @throws ConverterException |
|
| 78 | * @return \DateInterval $data |
|
| 79 | */ |
|
| 80 | protected function checkData($data) |
|
| 81 | { |
|
| 82 | if (!$data instanceof \DateInterval) { |
|
| 83 | try { |
|
| 84 | $data = new \DateInterval($data); |
|
| 85 | } catch (\Exception $e) { |
|
| 86 | throw new ConverterException("First argument is not a \DateInterval instance.", null, $e); |
|
| 87 | } |
|
| 88 | } |
|
| 89 | ||
| 90 | return $data; |
|
| 91 | } |
|
| 92 | } |
|
| 93 | ||
| @@ 79-97 (lines=19) @@ | ||
| 76 | * @throws ConverterException |
|
| 77 | * @return \DateTime |
|
| 78 | */ |
|
| 79 | protected function checkData($data) |
|
| 80 | { |
|
| 81 | if (!$data instanceof \DateTimeInterface) { |
|
| 82 | try { |
|
| 83 | $data = new \DateTime($data); |
|
| 84 | } catch (\Exception $e) { |
|
| 85 | throw new ConverterException( |
|
| 86 | sprintf( |
|
| 87 | "Cannot convert data from invalid datetime representation '%s'.", |
|
| 88 | $data |
|
| 89 | ), |
|
| 90 | null, |
|
| 91 | $e |
|
| 92 | ); |
|
| 93 | } |
|
| 94 | } |
|
| 95 | ||
| 96 | return $data; |
|
| 97 | } |
|
| 98 | } |
|
| 99 | ||