1 | <?php |
||
17 | class GlobeCoordinateValue extends DataValueObject { |
||
18 | |||
19 | /** |
||
20 | * @var LatLongValue |
||
21 | */ |
||
22 | private $latLong; |
||
23 | |||
24 | /** |
||
25 | * The precision of the coordinate in degrees, e.g. 0.01. |
||
26 | * |
||
27 | * @var float|null |
||
28 | */ |
||
29 | private $precision; |
||
30 | |||
31 | /** |
||
32 | * IRI of the globe on which the location resides. |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | private $globe; |
||
37 | |||
38 | /** |
||
39 | * Wikidata concept URI for the Earth. Used as default value when no other globe was specified. |
||
40 | */ |
||
41 | public const GLOBE_EARTH = 'http://www.wikidata.org/entity/Q2'; |
||
42 | |||
43 | /** |
||
44 | * @param LatLongValue $latLong |
||
45 | * @param float|int|null $precision in degrees, e.g. 0.01. |
||
46 | * @param string|null $globe IRI, defaults to 'http://www.wikidata.org/entity/Q2'. |
||
47 | * |
||
48 | * @throws IllegalValueException |
||
49 | */ |
||
50 | 70 | public function __construct( LatLongValue $latLong, float $precision = null, string $globe = null ) { |
|
63 | |||
64 | 70 | private function assertIsPrecision( ?float $precision ) { |
|
69 | |||
70 | /** |
||
71 | * @see Serializable::serialize |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | 48 | public function serialize(): string { |
|
78 | |||
79 | /** |
||
80 | * @see Serializable::unserialize |
||
81 | * |
||
82 | * @param string $value |
||
83 | * |
||
84 | * @throws IllegalValueException |
||
85 | */ |
||
86 | 49 | public function unserialize( $value ) { |
|
90 | |||
91 | /** |
||
92 | * @see DataValue::getType |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | 32 | public static function getType(): string { |
|
99 | |||
100 | /** |
||
101 | * @see DataValue::getSortKey |
||
102 | * |
||
103 | * @return float |
||
104 | */ |
||
105 | public function getSortKey(): float { |
||
108 | |||
109 | 18 | public function getLatitude(): float { |
|
112 | |||
113 | 18 | public function getLongitude(): float { |
|
116 | |||
117 | /** |
||
118 | * @see DataValue::getValue |
||
119 | * |
||
120 | * @return self |
||
121 | */ |
||
122 | 16 | public function getValue(): self { |
|
125 | |||
126 | public function getLatLong(): LatLongValue { |
||
129 | |||
130 | /** |
||
131 | * Returns the precision of the coordinate in degrees, e.g. 0.01. |
||
132 | * |
||
133 | * @return float|int|null |
||
134 | */ |
||
135 | 18 | public function getPrecision(): ?float { |
|
138 | |||
139 | /** |
||
140 | * Returns the IRI of the globe on which the location resides. |
||
141 | * |
||
142 | * @return string |
||
143 | */ |
||
144 | 18 | public function getGlobe(): string { |
|
147 | |||
148 | /** |
||
149 | * @see Hashable::getHash |
||
150 | * |
||
151 | * @since 2.0 |
||
152 | * |
||
153 | * @return string |
||
154 | */ |
||
155 | 17 | public function getHash(): string { |
|
161 | |||
162 | /** |
||
163 | * @see DataValue::getArrayValue |
||
164 | * |
||
165 | * @return array |
||
166 | */ |
||
167 | 80 | public function getArrayValue(): array { |
|
180 | |||
181 | /** |
||
182 | * Constructs a new instance from the provided data. Required for @see DataValueDeserializer. |
||
183 | * This is expected to round-trip with @see getArrayValue. |
||
184 | * |
||
185 | * @deprecated since 2.0.1. Static DataValue::newFromArray constructors like this are |
||
186 | * underspecified (not in the DataValue interface), and misleadingly named (should be named |
||
187 | * newFromArrayValue). Instead, use DataValue builder callbacks in @see DataValueDeserializer. |
||
188 | * |
||
189 | * @param mixed $data Warning! Even if this is expected to be a value as returned by |
||
190 | * @see getArrayValue, callers of this specific newFromArray implementation can not guarantee |
||
191 | * this. This is not even guaranteed to be an array! |
||
192 | * |
||
193 | * @throws IllegalValueException if $data is not in the expected format. Subclasses of |
||
194 | * InvalidArgumentException are expected and properly handled by @see DataValueDeserializer. |
||
195 | * @return self |
||
196 | */ |
||
197 | 6 | public static function newFromArray( $data ): self { |
|
209 | |||
210 | } |
||
211 |
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.