Completed
Pull Request — master (#83)
by
unknown
02:12
created

PgBox   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTypeClassName() 0 4 1
A toPg() 0 16 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 Miha Vrhovnik
24
 * @license X11 {@link http://opensource.org/licenses/mit-license.php}
25
 * @see ConverterInterface
26
 */
27
class PgBox extends TypeConverter
28
{
29
    /**
30
     * getTypeClassName
31
     *
32
     * @see TypeConverter
33
     */
34
    public function getTypeClassName()
35
    {
36
        return '\PommProject\Foundation\Converter\Type\Box';
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
            "box((%s,%s),(%s,%s))",
54
            $data->topX,
55
            $data->topY,
56
            $data->bottomX,
57
            $data->bottomY
58
        );
59
    }
60
}
61