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.

HeatmapLayer   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 84
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 2
dl 84
loc 84
ccs 28
cts 28
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() 6 6 2
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\Layer;
13
14
use Ivory\GoogleMap\Base\Coordinate;
15
use Ivory\GoogleMap\Overlay\ExtendableInterface;
16
use Ivory\GoogleMap\Utility\OptionsAwareInterface;
17
use Ivory\GoogleMap\Utility\OptionsAwareTrait;
18
use Ivory\GoogleMap\Utility\VariableAwareTrait;
19
20
/**
21
 * @author GeLo <[email protected]>
22
 */
23 View Code Duplication
class HeatmapLayer 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...
24
{
25
    use OptionsAwareTrait;
26
    use VariableAwareTrait;
27
28
    /**
29
     * @var Coordinate[]
30
     */
31
    private $coordinates = [];
32
33
    /**
34
     * @param Coordinate[] $coordinates
35
     * @param mixed[]      $options
36
     */
37 48
    public function __construct(array $coordinates = [], array $options = [])
38
    {
39 48
        $this->setCoordinates($coordinates);
40 48
        $this->setOptions($options);
41 48
    }
42
43
    /**
44
     * @return bool
45
     */
46 24
    public function hasCoordinates()
47
    {
48 24
        return !empty($this->coordinates);
49
    }
50
51
    /**
52
     * @return Coordinate[]
53
     */
54 40
    public function getCoordinates()
55
    {
56 40
        return $this->coordinates;
57
    }
58
59
    /**
60
     * @param Coordinate[] $coordinates
61
     */
62 48
    public function setCoordinates(array $coordinates)
63
    {
64 48
        $this->coordinates = [];
65 48
        $this->addCoordinates($coordinates);
66 48
    }
67
68
    /**
69
     * @param Coordinate[] $coordinates
70
     */
71 48
    public function addCoordinates(array $coordinates)
72
    {
73 48
        foreach ($coordinates as $coordinate) {
74 28
            $this->addCoordinate($coordinate);
75 24
        }
76 48
    }
77
78
    /**
79
     * @param Coordinate $coordinate
80
     *
81
     * @return bool
82
     */
83 36
    public function hasCoordinate(Coordinate $coordinate)
84
    {
85 36
        return in_array($coordinate, $this->coordinates, true);
86
    }
87
88
    /**
89
     * @param Coordinate $coordinate
90
     */
91 36
    public function addCoordinate(Coordinate $coordinate)
92
    {
93 36
        if (!$this->hasCoordinate($coordinate)) {
94 36
            $this->coordinates[] = $coordinate;
95 18
        }
96 36
    }
97
98
    /**
99
     * @param Coordinate $coordinate
100
     */
101 4
    public function removeCoordinate(Coordinate $coordinate)
102
    {
103 4
        unset($this->coordinates[array_search($coordinate, $this->coordinates, true)]);
104 4
        $this->coordinates = empty($this->coordinates) ? [] : array_values($this->coordinates);
105 4
    }
106
}
107