1 | <?php |
||
20 | class GlobeCoordinateValue implements DataValue { |
||
21 | |||
22 | private $latLong; |
||
23 | |||
24 | /** |
||
25 | * @var float|null |
||
26 | */ |
||
27 | private $precision; |
||
28 | |||
29 | /** |
||
30 | * IRI of the globe on which the location resides. |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | private $globe; |
||
35 | |||
36 | /** |
||
37 | * Wikidata concept URI for the Earth. Used as default value when no other globe was specified. |
||
38 | */ |
||
39 | public const GLOBE_EARTH = 'http://www.wikidata.org/entity/Q2'; |
||
40 | |||
41 | /** |
||
42 | * @param LatLongValue $latLong |
||
43 | * @param float|int|null $precision in degrees, e.g. 0.01. |
||
44 | * @param string|null $globe IRI, defaults to 'http://www.wikidata.org/entity/Q2'. |
||
45 | * |
||
46 | * @throws IllegalValueException |
||
47 | */ |
||
48 | 82 | public function __construct( LatLongValue $latLong, float $precision = null, string $globe = null ) { |
|
61 | |||
62 | 82 | private function assertIsPrecision( ?float $precision ) { |
|
67 | |||
68 | 1 | public function getLatLong(): LatLongValue { |
|
71 | |||
72 | /** |
||
73 | * Returns the precision of the coordinate in degrees, e.g. 0.01. |
||
74 | */ |
||
75 | 14 | public function getPrecision(): ?float { |
|
78 | |||
79 | /** |
||
80 | * Returns the IRI of the globe on which the location resides. |
||
81 | */ |
||
82 | 8 | public function getGlobe(): string { |
|
85 | |||
86 | 19 | public function getLatitude(): float { |
|
89 | |||
90 | 3 | public function getLongitude(): float { |
|
93 | |||
94 | /** |
||
95 | * @see \Comparable::equals |
||
96 | */ |
||
97 | 32 | public function equals( $target ): bool { |
|
103 | |||
104 | 16 | public function getCopy(): self { |
|
111 | |||
112 | /** |
||
113 | * @see Hashable::getHash |
||
114 | * |
||
115 | * @since 2.0 |
||
116 | */ |
||
117 | 1 | public function getHash(): string { |
|
125 | |||
126 | /** |
||
127 | * @see Serializable::serialize |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | 16 | public function serialize(): string { |
|
134 | |||
135 | /** |
||
136 | * @see Serializable::unserialize |
||
137 | * |
||
138 | * @param string $value |
||
139 | * |
||
140 | * @throws InvalidArgumentException |
||
141 | */ |
||
142 | 17 | public function unserialize( $value ) { |
|
146 | |||
147 | /** |
||
148 | * @see DataValue::getType |
||
149 | */ |
||
150 | 3 | public static function getType(): string { |
|
151 | 3 | return 'globecoordinate'; |
|
152 | } |
||
153 | |||
154 | /** |
||
155 | * @see DataValue::getSortKey |
||
156 | */ |
||
157 | 16 | public function getSortKey(): float { |
|
160 | |||
161 | /** |
||
162 | * @see DataValue::getValue |
||
163 | */ |
||
164 | 16 | public function getValue(): self { |
|
167 | |||
168 | /** |
||
169 | * @see DataValue::getArrayValue |
||
170 | */ |
||
171 | 34 | public function getArrayValue(): array { |
|
184 | |||
185 | 2 | public function toArray(): array { |
|
186 | return [ |
||
187 | 2 | 'value' => $this->getArrayValue(), |
|
188 | 2 | 'type' => $this->getType(), |
|
189 | ]; |
||
190 | } |
||
191 | |||
192 | 5 | public function withPrecision( ?float $precision ): self { |
|
199 | |||
200 | /** |
||
201 | * Constructs a new instance from the provided array. Round-trips with @see getArrayValue. |
||
202 | * |
||
203 | * @throws InvalidArgumentException |
||
204 | */ |
||
205 | 25 | public static function newFromArray( $data ): self { |
|
227 | |||
228 | } |
||
229 |
This checks looks for assignemnts to variables using the
list(...)
function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$a
and$c
are used. There was no need to assign$b
.Instead, the list call could have been.