Completed
Push — master ( 5ba831...bd1989 )
by grégoire
01:54
created

PgBox   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTypeClassName() 4 4 1
A toPg() 13 13 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
 * PgBox
18
 *
19
 * Converter for PostgreSQL box type.
20
 *
21
 * @package Foundation
22
 * @copyright 2017 Grégoire HUBERT
23
 * @author Miha Vrhovnik
24
 * @license X11 {@link http://opensource.org/licenses/mit-license.php}
25
 * @see ConverterInterface
26
 */
27 View Code Duplication
class PgBox extends TypeConverter
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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",
54
            (string)$data
55
        );
56
    }
57
}
58