1 | <?php |
||
19 | class LatLongValue extends DataValueObject { |
||
20 | |||
21 | private $latitude; |
||
22 | private $longitude; |
||
23 | |||
24 | /** |
||
25 | * @param float|int $latitude Latitude in degrees within the range [-360, 360] |
||
26 | * @param float|int $longitude Longitude in degrees within the range [-360, 360] |
||
27 | * |
||
28 | * @throws InvalidArgumentException |
||
29 | */ |
||
30 | 49 | public function __construct( float $latitude, float $longitude ) { |
|
37 | |||
38 | 49 | private function assertIsLatitude( float $latitude ) { |
|
43 | |||
44 | 44 | private function assertIsLongitude( float $longitude ) { |
|
49 | |||
50 | /** |
||
51 | * @see Serializable::serialize |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | 30 | public function serialize(): string { |
|
63 | |||
64 | /** |
||
65 | * @see Serializable::unserialize |
||
66 | * |
||
67 | * @param string $value |
||
68 | * |
||
69 | * @throws InvalidArgumentException |
||
70 | */ |
||
71 | 30 | public function unserialize( $value ) { |
|
80 | |||
81 | /** |
||
82 | * @see DataValue::getType |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | 20 | public static function getType(): string { |
|
90 | |||
91 | /** |
||
92 | * @see DataValue::getSortKey |
||
93 | * |
||
94 | * @return float |
||
95 | */ |
||
96 | public function getSortKey(): float { |
||
99 | |||
100 | /** |
||
101 | * @see DataValue::getValue |
||
102 | * |
||
103 | * @return self |
||
104 | */ |
||
105 | 10 | public function getValue(): self { |
|
108 | |||
109 | 10 | public function getLatitude(): float { |
|
112 | |||
113 | 10 | public function getLongitude(): float { |
|
116 | |||
117 | /** |
||
118 | * @see DataValue::getArrayValue |
||
119 | * |
||
120 | * @return float[] |
||
121 | */ |
||
122 | 20 | public function getArrayValue(): array { |
|
128 | |||
129 | /** |
||
130 | * Constructs a new instance from the provided data. Required for @see DataValueDeserializer. |
||
131 | * This is expected to round-trip with @see getArrayValue. |
||
132 | * |
||
133 | * @deprecated since 2.0.1. Static DataValue::newFromArray constructors like this are |
||
134 | * underspecified (not in the DataValue interface), and misleadingly named (should be named |
||
135 | * newFromArrayValue). Instead, use DataValue builder callbacks in @see DataValueDeserializer. |
||
136 | * |
||
137 | * @param mixed $data Warning! Even if this is expected to be a value as returned by |
||
138 | * @see getArrayValue, callers of this specific newFromArray implementation can not guarantee |
||
139 | * this. This is not even guaranteed to be an array! |
||
140 | * |
||
141 | * @throws InvalidArgumentException if $data is not in the expected format. Subclasses of |
||
142 | * InvalidArgumentException are expected and properly handled by @see DataValueDeserializer. |
||
143 | * @return self |
||
144 | */ |
||
145 | public static function newFromArray( $data ): self { |
||
150 | |||
151 | } |
||
152 |