GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Polygon   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 82
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 10
lcom 1
cbo 2
dl 82
loc 82
ccs 26
cts 26
cp 1
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A hasCoordinates() 4 4 1
A getCoordinates() 4 4 1
A setCoordinates() 5 5 1
A addCoordinates() 6 6 2
A hasCoordinate() 4 4 1
A addCoordinate() 4 4 1
A removeCoordinate() 5 5 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
/*
4
 * This file is part of the Ivory Google Map package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMap\Overlay;
13
14
use Ivory\GoogleMap\Base\Coordinate;
15
use Ivory\GoogleMap\Utility\OptionsAwareInterface;
16
use Ivory\GoogleMap\Utility\OptionsAwareTrait;
17
use Ivory\GoogleMap\Utility\VariableAwareTrait;
18
19
/**
20
 * @see http://code.google.com/apis/maps/documentation/javascript/reference.html#Polygon
21
 *
22
 * @author GeLo <[email protected]>
23
 */
24 View Code Duplication
class Polygon implements ExtendableInterface, OptionsAwareInterface
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...
25
{
26
    use OptionsAwareTrait;
27
    use VariableAwareTrait;
28
29
    /**
30
     * @var Coordinate[]
31
     */
32
    private $coordinates = [];
33
34
    /**
35
     * @param Coordinate[] $coordinates
36
     * @param mixed[]      $options
37
     */
38 48
    public function __construct(array $coordinates = [], array $options = [])
39
    {
40 48
        $this->addCoordinates($coordinates);
41 48
        $this->addOptions($options);
42 48
    }
43
44
    /**
45
     * @return bool
46
     */
47 24
    public function hasCoordinates()
48
    {
49 24
        return !empty($this->coordinates);
50
    }
51
52
    /**
53
     * @return Coordinate[]
54
     */
55 40
    public function getCoordinates()
56
    {
57 40
        return $this->coordinates;
58
    }
59
60
    /**
61
     * @param Coordinate[] $coordinates
62
     */
63 8
    public function setCoordinates(array $coordinates)
64
    {
65 8
        $this->coordinates = [];
66 8
        $this->addCoordinates($coordinates);
67 8
    }
68
69
    /**
70
     * @param Coordinate[] $coordinates
71
     */
72 48
    public function addCoordinates(array $coordinates)
73
    {
74 48
        foreach ($coordinates as $coordinate) {
75 28
            $this->addCoordinate($coordinate);
76 24
        }
77 48
    }
78
79
    /**
80
     * @param Coordinate $coordinate
81
     *
82
     * @return bool
83
     */
84 16
    public function hasCoordinate(Coordinate $coordinate)
85
    {
86 16
        return in_array($coordinate, $this->coordinates, true);
87
    }
88
89
    /**
90
     * @param Coordinate $coordinate
91
     */
92 36
    public function addCoordinate(Coordinate $coordinate)
93
    {
94 36
        $this->coordinates[] = $coordinate;
95 36
    }
96
97
    /**
98
     * @param Coordinate $coordinate
99
     */
100 4
    public function removeCoordinate(Coordinate $coordinate)
101
    {
102 4
        unset($this->coordinates[array_search($coordinate, $this->coordinates, true)]);
103 4
        $this->coordinates = empty($this->coordinates) ? [] : array_values($this->coordinates);
104 4
    }
105
}
106