Code Duplication    Length = 12-19 lines in 2 locations

sources/lib/Converter/PgInterval.php 1 location

@@ 77-88 (lines=12) @@
74
     * @throws ConverterException
75
     * @return \DateInterval $data
76
     */
77
    protected function checkData($data)
78
    {
79
        if (!$data instanceof \DateInterval) {
80
            try {
81
                $data = new \DateInterval($data);
82
            } catch (\Exception $e) {
83
                throw new ConverterException("First argument is not a \DateInterval instance.", null, $e);
84
            }
85
        }
86
87
        return $data;
88
    }
89
}
90

sources/lib/Converter/PgTimestamp.php 1 location

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