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

PgPoint   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 3
Bugs 1 Features 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 32
c 3
b 1
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTypeClassName() 0 4 1
A toPg() 0 14 2
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