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.
Completed
Push — master ( 1faea8...2295f4 )
by Eric
03:10
created

ElevationResponse   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 100
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

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

10 Methods

Rating   Name   Duplication   Size   Complexity  
A hasStatus() 4 4 1
A getStatus() 4 4 1
A setStatus() 4 4 1
A hasResults() 4 4 1
A getResults() 4 4 1
A setResults() 5 5 1
A addResults() 6 6 2
A hasResult() 4 4 1
A addResult() 6 6 2
A removeResult() 5 5 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
/*
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\Service\Elevation\Response;
13
14
/**
15
 * @author GeLo <[email protected]>
16
 */
17 View Code Duplication
class ElevationResponse
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...
18
{
19
    /**
20
     * @var string|null
21
     */
22
    private $status;
23
24
    /**
25
     * @var ElevationResult[]
26
     */
27
    private $results = [];
28
29
    /**
30
     * @return bool
31
     */
32
    public function hasStatus()
33
    {
34
        return $this->status !== null;
35
    }
36
37
    /**
38
     * @return string|null
39
     */
40
    public function getStatus()
41
    {
42
        return $this->status;
43
    }
44
45
    /**
46
     * @param string|null $status
47
     */
48
    public function setStatus($status)
49
    {
50
        $this->status = $status;
51
    }
52
53
    /**
54
     * @return bool
55
     */
56
    public function hasResults()
57
    {
58
        return !empty($this->results);
59
    }
60
61
    /**
62
     * @return ElevationResult[]
63
     */
64
    public function getResults()
65
    {
66
        return $this->results;
67
    }
68
69
    /**
70
     * @param ElevationResult[] $results
71
     */
72
    public function setResults(array $results)
73
    {
74
        $this->results = [];
75
        $this->addResults($results);
76
    }
77
78
    /**
79
     * @param ElevationResult[] $results
80
     */
81
    public function addResults(array $results)
82
    {
83
        foreach ($results as $result) {
84
            $this->addResult($result);
85
        }
86
    }
87
88
    /**
89
     * @param ElevationResult $result
90
     *
91
     * @return bool
92
     */
93
    public function hasResult(ElevationResult $result)
94
    {
95
        return in_array($result, $this->results, true);
96
    }
97
98
    /**
99
     * @param ElevationResult $result
100
     */
101
    public function addResult(ElevationResult $result)
102
    {
103
        if (!$this->hasResult($result)) {
104
            $this->results[] = $result;
105
        }
106
    }
107
108
    /**
109
     * @param ElevationResult $result
110
     */
111
    public function removeResult(ElevationResult $result)
112
    {
113
        unset($this->results[array_search($result, $this->results, true)]);
114
        $this->results = array_values($this->results);
115
    }
116
}
117