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
Pull Request — master (#177)
by Eric
65:22 queued 62:22
created

AbstractTextualPlaceSearchRequest::addNames()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
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\Place\Search\Request;
13
14
/**
15
 * @author GeLo <[email protected]>
16
 */
17
abstract class AbstractTextualPlaceSearchRequest extends AbstractPlaceSearchRequest
18
{
19
    /**
20
     * @var string|null
21
     */
22
    private $keyword;
23
24
    /**
25
     * @var string[]
26
     */
27
    private $names = [];
28
29
    /**
30
     * @return bool
31
     */
32
    public function hasKeyword()
33
    {
34
        return $this->keyword !== null;
35
    }
36
37
    /**
38
     * @return string|null
39
     */
40
    public function getKeyword()
41
    {
42
        return $this->keyword;
43
    }
44
45
    /**
46
     * @param string|null $keyword
47
     */
48
    public function setKeyword($keyword)
49
    {
50
        $this->keyword = $keyword;
51
    }
52
53
    /**
54
     * @return bool
55
     */
56
    public function hasNames()
57
    {
58
        return !empty($this->names);
59
    }
60
61
    /**
62
     * @return string[]
63
     */
64
    public function getNames()
65
    {
66
        return $this->names;
67
    }
68
69
    /**
70
     * @param string[] $names
71
     */
72
    public function setNames(array $names)
73
    {
74
        $this->names = [];
75
        $this->addNames($names);
76
    }
77
78
    /**
79
     * @param string[] $names
80
     */
81
    public function addNames(array $names)
82
    {
83
        foreach ($names as $name) {
84
            $this->addName($name);
85
        }
86
    }
87
88
    /**
89
     * @param string $name
90
     *
91
     * @return bool
92
     */
93
    public function hasName($name)
94
    {
95
        return in_array($name, $this->names, true);
96
    }
97
98
    /**
99
     * @param string $name
100
     */
101
    public function addName($name)
102
    {
103
        if (!$this->hasName($name)) {
104
            $this->names[] = $name;
105
        }
106
    }
107
108
    /**
109
     * @param string $name
110
     */
111
    public function removeName($name)
112
    {
113
        unset($this->names[array_search($name, $this->names, true)]);
114
        $this->names = array_values($this->names);
115
    }
116
117
    /**
118
     * {@inheritdoc}
119
     */
120
    public function buildQuery()
121
    {
122
        $query = parent::buildQuery();
123
124
        if ($this->hasKeyword()) {
125
            $query['keyword'] = $this->keyword;
126
        }
127
128
        if ($this->hasNames()) {
129
            $query['name'] = implode('|', $this->names);
130
        }
131
132
        return $query;
133
    }
134
}
135