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 | 75 | public function __construct( LatLongValue $latLong, float $precision = null, string $globe = null ) { |
|
61 | |||
62 | 75 | private function assertIsPrecision( ?float $precision ) { |
|
67 | |||
68 | /** |
||
69 | * @see Serializable::serialize |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | 16 | public function serialize(): string { |
|
76 | |||
77 | /** |
||
78 | * @see Serializable::unserialize |
||
79 | * |
||
80 | * @param string $value |
||
81 | * |
||
82 | * @throws InvalidArgumentException |
||
83 | */ |
||
84 | 17 | public function unserialize( $value ) { |
|
88 | |||
89 | /** |
||
90 | * @see DataValue::getType |
||
91 | */ |
||
92 | public static function getType(): string { |
||
95 | |||
96 | /** |
||
97 | * @see DataValue::getSortKey |
||
98 | */ |
||
99 | 16 | public function getSortKey(): float { |
|
102 | |||
103 | 19 | public function getLatitude(): float { |
|
106 | |||
107 | 3 | public function getLongitude(): float { |
|
110 | |||
111 | /** |
||
112 | * @see DataValue::getValue |
||
113 | */ |
||
114 | 16 | public function getValue(): self { |
|
117 | |||
118 | 1 | public function getLatLong(): LatLongValue { |
|
121 | |||
122 | /** |
||
123 | * Returns the precision of the coordinate in degrees, e.g. 0.01. |
||
124 | */ |
||
125 | 14 | public function getPrecision(): ?float { |
|
128 | |||
129 | /** |
||
130 | * Returns the IRI of the globe on which the location resides. |
||
131 | */ |
||
132 | 8 | public function getGlobe(): string { |
|
135 | |||
136 | /** |
||
137 | * @see Hashable::getHash |
||
138 | * |
||
139 | * @since 2.0 |
||
140 | */ |
||
141 | 1 | public function getHash(): string { |
|
149 | |||
150 | /** |
||
151 | * @see DataValue::getArrayValue |
||
152 | */ |
||
153 | 32 | public function getArrayValue(): array { |
|
166 | |||
167 | /** |
||
168 | * @see \Comparable::equals |
||
169 | */ |
||
170 | 32 | public function equals( $target ): bool { |
|
176 | |||
177 | 16 | public function getCopy(): self { |
|
184 | |||
185 | public function toArray(): array { |
||
191 | |||
192 | /** |
||
193 | * Constructs a new instance from the provided array. Round-trips with @see getArrayValue. |
||
194 | * |
||
195 | * @throws InvalidArgumentException |
||
196 | */ |
||
197 | 25 | public static function newFromArray( $data ): self { |
|
219 | |||
220 | } |
||
221 |
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.