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 ( 763674...126977 )
by Eric
02:32
created

GeocoderResponse::addResult()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
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\Geocoder\Response;
13
14
/**
15
 * @author GeLo <[email protected]>
16
 */
17
class GeocoderResponse
18
{
19
    /**
20
     * @var string|null
21
     */
22
    private $status;
23
24
    /**
25
     * @var GeocoderResult[]
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 = null)
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 GeocoderResult[]
63
     */
64
    public function getResults()
65
    {
66
        return $this->results;
67
    }
68
69
    /**
70
     * @param GeocoderResult[] $results
71
     */
72
    public function setResults(array $results)
73
    {
74
        $this->results = [];
75
        $this->addResults($results);
76
    }
77
78
    /**
79
     * @param GeocoderResult[] $results
80
     */
81
    public function addResults(array $results)
82
    {
83
        foreach ($results as $result) {
84
            $this->addResult($result);
85
        }
86
    }
87
88
    /**
89
     * @param GeocoderResult $result
90
     *
91
     * @return bool
92
     */
93
    public function hasResult(GeocoderResult $result)
94
    {
95
        return in_array($result, $this->results, true);
96
    }
97
98
    /**
99
     * @param GeocoderResult $result
100
     */
101
    public function addResult(GeocoderResult $result)
102
    {
103
        if (!$this->hasResult($result)) {
104
            $this->results[] = $result;
105
        }
106
    }
107
108
    /**
109
     * @param GeocoderResult $result
110
     */
111
    public function removeResult(GeocoderResult $result)
112
    {
113
        unset($this->results[array_search($result, $this->results, true)]);
114
        $this->results = array_values($this->results);
115
    }
116
}
117