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 (#165)
by Eric
06:03 queued 03:27
created

DistanceMatrixRow::setElements()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
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 5
rs 9.4285
cc 1
eloc 3
nc 1
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\DistanceMatrix\Response;
13
14
/**
15
 * @author GeLo <[email protected]>
16
 */
17
class DistanceMatrixRow
18
{
19
    /**
20
     * @var DistanceMatrixElement[]
21
     */
22
    private $elements = [];
23
24
    /**
25
     * @return bool
26
     */
27
    public function hasElements()
28
    {
29
        return !empty($this->elements);
30
    }
31
32
    /**
33
     * @return DistanceMatrixElement[]
34
     */
35
    public function getElements()
36
    {
37
        return $this->elements;
38
    }
39
40
    /**
41
     * @param DistanceMatrixElement[] $elements
42
     */
43
    public function setElements(array $elements)
44
    {
45
        $this->elements = [];
46
        $this->addElements($elements);
47
    }
48
49
    /**
50
     * @param DistanceMatrixElement[] $elements
51
     */
52
    public function addElements(array $elements)
53
    {
54
        foreach ($elements as $element) {
55
            $this->addElement($element);
56
        }
57
    }
58
59
    /**
60
     * @param DistanceMatrixElement $element
61
     *
62
     * @return bool
63
     */
64
    public function hasElement(DistanceMatrixElement $element)
65
    {
66
        return in_array($element, $this->elements, true);
67
    }
68
69
    /**
70
     * @param DistanceMatrixElement $element
71
     */
72
    public function addElement(DistanceMatrixElement $element)
73
    {
74
        if (!$this->hasElement($element)) {
75
            $this->elements[] = $element;
76
        }
77
    }
78
79
    /**
80
     * @param DistanceMatrixElement $element
81
     */
82
    public function removeElement(DistanceMatrixElement $element)
83
    {
84
        unset($this->elements[array_search($element, $this->elements, true)]);
85
        $this->elements = array_values($this->elements);
86
    }
87
}
88