|
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
|
|
|
|