1 | <?php |
||
20 | class LatLongValue extends DataValueObject { |
||
21 | |||
22 | /** |
||
23 | * The locations latitude. |
||
24 | * |
||
25 | * @var float |
||
26 | */ |
||
27 | private $latitude; |
||
28 | |||
29 | /** |
||
30 | * The locations longitude. |
||
31 | * |
||
32 | * @var float |
||
33 | */ |
||
34 | private $longitude; |
||
35 | |||
36 | /** |
||
37 | * @param float|int $latitude |
||
38 | * @param float|int $longitude |
||
39 | * |
||
40 | * @throws InvalidArgumentException |
||
41 | */ |
||
42 | 45 | public function __construct( float $latitude, float $longitude ) { |
|
57 | |||
58 | 45 | private function assertIsLatitude( float $latitude ) { |
|
63 | |||
64 | 42 | private function assertIsLongitude( float $longitude ) { |
|
69 | |||
70 | /** |
||
71 | * @see Serializable::serialize |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | 30 | public function serialize(): string { |
|
83 | |||
84 | /** |
||
85 | * @see Serializable::unserialize |
||
86 | * |
||
87 | * @param string $value |
||
88 | * |
||
89 | * @throws InvalidArgumentException |
||
90 | */ |
||
91 | 30 | public function unserialize( $value ) { |
|
100 | |||
101 | /** |
||
102 | * @see DataValue::getType |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | 20 | public static function getType(): string { |
|
110 | |||
111 | /** |
||
112 | * @see DataValue::getSortKey |
||
113 | * |
||
114 | * @return float |
||
115 | */ |
||
116 | public function getSortKey(): float { |
||
119 | |||
120 | /** |
||
121 | * @see DataValue::getValue |
||
122 | * |
||
123 | * @return self |
||
124 | */ |
||
125 | 10 | public function getValue(): self { |
|
128 | |||
129 | 10 | public function getLatitude(): float { |
|
132 | |||
133 | 10 | public function getLongitude(): float { |
|
136 | |||
137 | /** |
||
138 | * @see DataValue::getArrayValue |
||
139 | * |
||
140 | * @return float[] |
||
141 | */ |
||
142 | 20 | public function getArrayValue(): array { |
|
148 | |||
149 | /** |
||
150 | * Constructs a new instance from the provided data. Required for @see DataValueDeserializer. |
||
151 | * This is expected to round-trip with @see getArrayValue. |
||
152 | * |
||
153 | * @deprecated since 2.0.1. Static DataValue::newFromArray constructors like this are |
||
154 | * underspecified (not in the DataValue interface), and misleadingly named (should be named |
||
155 | * newFromArrayValue). Instead, use DataValue builder callbacks in @see DataValueDeserializer. |
||
156 | * |
||
157 | * @param mixed $data Warning! Even if this is expected to be a value as returned by |
||
158 | * @see getArrayValue, callers of this specific newFromArray implementation can not guarantee |
||
159 | * this. This is not even guaranteed to be an array! |
||
160 | * |
||
161 | * @throws InvalidArgumentException if $data is not in the expected format. Subclasses of |
||
162 | * InvalidArgumentException are expected and properly handled by @see DataValueDeserializer. |
||
163 | * @return self |
||
164 | */ |
||
165 | public static function newFromArray( $data ): self { |
||
170 | |||
171 | } |
||
172 |