Code Duplication    Length = 46-46 lines in 2 locations

sources/lib/Converter/PgFloat.php 1 location

@@ 25-70 (lines=46) @@
22
 * @license   X11 {@link http://opensource.org/licenses/mit-license.php}
23
 * @see       ConverterInterface
24
 */
25
class PgFloat implements ConverterInterface
26
{
27
    /**
28
     * fromPg
29
     *
30
     * @see ConverterInterface
31
     */
32
    public function fromPg($data, $type, Session $session)
33
    {
34
        $data = trim($data);
35
36
        if ($data === '') {
37
            return null;
38
        }
39
40
        return (float)$data;
41
    }
42
43
    /**
44
     * toPg
45
     *
46
     * @see ConverterInterface
47
     */
48
    public function toPg($data, $type, Session $session)
49
    {
50
        return
51
            $data !== null
52
            ? sprintf("%s '%s'", $type, $data)
53
            : sprintf("NULL::%s", $type)
54
            ;
55
    }
56
57
    /**
58
     * toPgStandardFormat
59
     *
60
     * @see ConverterInterface
61
     */
62
    public function toPgStandardFormat($data, $type, Session $session)
63
    {
64
        return
65
            $data !== null
66
            ? sprintf('%s', $data)
67
            : null
68
            ;
69
    }
70
}
71

sources/lib/Converter/PgInteger.php 1 location

@@ 25-70 (lines=46) @@
22
 * @license   X11 {@link http://opensource.org/licenses/mit-license.php}
23
 * @see       ConverterInterface
24
 */
25
class PgInteger implements ConverterInterface
26
{
27
    /**
28
     * fromPg
29
     *
30
     * @see ConverterInterface
31
     */
32
    public function fromPg($data, $type, Session $session)
33
    {
34
        $data = trim($data);
35
36
        if ($data === '') {
37
            return null;
38
        }
39
40
        return (int)$data;
41
    }
42
43
    /**
44
     * toPg
45
     *
46
     * @see ConverterInterface
47
     */
48
    public function toPg($data, $type, Session $session)
49
    {
50
        return
51
            $data !== null
52
            ? sprintf("%s '%u'", $type, $data)
53
            : sprintf("NULL::%s", $type)
54
            ;
55
    }
56
57
    /**
58
     * toPgStandardFormat
59
     *
60
     * @see ConverterInterface
61
     */
62
    public function toPgStandardFormat($data, $type, Session $session)
63
    {
64
        return
65
            $data !== null
66
            ? sprintf('%u', $data)
67
            : null
68
            ;
69
    }
70
}
71