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