Completed
Push — develop ( c61561...247dd8 )
by
unknown
09:15
created

Coordinates   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 73
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 2
dl 73
loc 73
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setType() 6 6 1
A getType() 4 4 1
A setCoordinates() 6 6 1
A getCoordinates() 4 4 1
A toJson() 9 9 1

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
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 */
9
10
/** Coordinates.php */
11
namespace Core\Entity;
12
13
use Core\Entity\AbstractEntity;
14
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
15
use Zend\Json\Json;
16
17
/**
18
 * Coordinate of a job position
19
 *
20
 * @ODM\EmbeddedDocument
21
 *
22
 */
23 View Code Duplication
class Coordinates extends AbstractEntity implements CoordinatesInterface
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...
24
{
25
    /**
26
     * The GeoJSON type
27
     *
28
     * @var string
29
     * @ODM\Field(type="string")
30
     */
31
    protected $type;
32
33
    /**
34
     * The GeoJSON coordinates.
35
     *
36
     * This is an array which format depends on the $type beeing used.
37
     *
38
     * @var array
39
     * @ODM\Collection
40
     */
41
    protected $coordinates;
42
43
    /**
44
     * @param $type
45
     *
46
     * @return $this
47
     */
48
    public function setType($type)
49
    {
50
        $this->type = $type;
51
52
        return $this;
53
    }
54
55
    /**
56
     * @return string
57
     */
58
    public function getType()
59
    {
60
        return $this->type;
61
    }
62
63
    /**
64
     * @param array $coordinates
65
     *
66
     * @return $this
67
     */
68
    public function setCoordinates(array $coordinates)
69
    {
70
        $this->coordinates = $coordinates;
71
72
        return $this;
73
    }
74
75
    /**
76
     * @return array
77
     */
78
    public function getCoordinates()
79
    {
80
        return $this->coordinates;
81
    }
82
83
    /**
84
     * @return string
85
     */
86
    public function toJson()
87
    {
88
        $data = [
89
            'type' => $this->getType(),
90
            'coordinates' => $this->getCoordinates(),
91
        ];
92
93
        return Json::encode($data);
94
    }
95
}
96