Completed
Push — 2.0 ( 143803...4e64fa )
by grégoire
08:42 queued 04:22
created

PgPoint::getTypeClassName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 4
c 1
b 1
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/*
3
 * This file is part of PommProject's Foundation package.
4
 *
5
 * (c) 2014 Grégoire HUBERT <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PommProject\Foundation\Converter\Geometry;
11
12
use PommProject\Foundation\Converter\TypeConverter;
13
use PommProject\Foundation\Converter\ConverterInterface;
14
use PommProject\Foundation\Session\Session;
15
16
/**
17
 * PgPoint
18
 *
19
 * Converter for PostgreSQL point type.
20
 *
21
 * @package Foundation
22
 * @copyright 2014 Grégoire HUBERT
23
 * @author Grégoire HUBERT
24
 * @license X11 {@link http://opensource.org/licenses/mit-license.php}
25
 * @see ConverterInterface
26
 */
27
class PgPoint extends TypeConverter
28
{
29
    /**
30
     * getTypeClassName
31
     *
32
     * @see TypeConverter
33
     */
34
    public function getTypeClassName()
35
    {
36
        return '\PommProject\Foundation\Converter\Type\Point';
37
    }
38
39
    /**
40
     * toPg
41
     *
42
     * @see ConverterInterface
43
     */
44
    public function toPg($data, $type, Session $session)
45
    {
46
        if ($data === null) {
47
            return sprintf("NULL::%s", $type);
48
        }
49
50
        $data = $this->checkData($data);
51
52
        return sprintf(
53
            "point(%s,%s)",
54
            $data->x,
55
            $data->y
56
        );
57
    }
58
}
59