PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
media-cloud-sync / includes / sdk / google / ramsey / uuid / src / DeprecatedUuidMethodsTrait.php

DeprecatedUuidMethodsTrait.php in Media Cloud Sync 1.4.2, at includes/sdk/google/ramsey/uuid/src/DeprecatedUuidMethodsTrait.php

280 lines 12.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * This file is part of the ramsey/uuid library
5 *
6 * For the full copyright and license information, please view the LICENSE
7 * file that was distributed with this source code.
8 *
9 * @copyright Copyright (c) Ben Ramsey <[email protected]>
10 * @license http://opensource.org/licenses/MIT MIT
11 */
12 declare (strict_types=1);
13 namespace Dudlewebs\WPMCS\GCP\Ramsey\Uuid;
14
15 use DateTimeImmutable;
16 use DateTimeInterface;
17 use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Converter\NumberConverterInterface;
18 use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Exception\DateTimeException;
19 use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Exception\UnsupportedOperationException;
20 use Throwable;
21 use function str_pad;
22 use function substr;
23 use const STR_PAD_LEFT;
24 /**
25 * This trait encapsulates deprecated methods for ramsey/uuid; this trait and its methods will be removed in ramsey/uuid 5.0.0.
26 *
27 * @deprecated This trait and its methods will be removed in ramsey/uuid 5.0.0.
28 *
29 * @immutable
30 */
31 trait DeprecatedUuidMethodsTrait
32 {
33 /**
34 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
35 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
36 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqHiAndReserved()} and use the arbitrary-precision math
37 * library of your choice to convert it to a string integer.
38 */
39 public function getClockSeqHiAndReserved() : string
40 {
41 return $this->numberConverter->fromHex($this->fields->getClockSeqHiAndReserved()->toString());
42 }
43 /**
44 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
45 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
46 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqHiAndReserved()}.
47 */
48 public function getClockSeqHiAndReservedHex() : string
49 {
50 return $this->fields->getClockSeqHiAndReserved()->toString();
51 }
52 /**
53 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
54 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
55 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqLow()} and use the arbitrary-precision math library of
56 * your choice to convert it to a string integer.
57 */
58 public function getClockSeqLow() : string
59 {
60 return $this->numberConverter->fromHex($this->fields->getClockSeqLow()->toString());
61 }
62 /**
63 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
64 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
65 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeqLow()}.
66 */
67 public function getClockSeqLowHex() : string
68 {
69 return $this->fields->getClockSeqLow()->toString();
70 }
71 /**
72 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
73 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
74 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeq()} and use the arbitrary-precision math library of
75 * your choice to convert it to a string integer.
76 */
77 public function getClockSequence() : string
78 {
79 return $this->numberConverter->fromHex($this->fields->getClockSeq()->toString());
80 }
81 /**
82 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
83 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
84 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getClockSeq()}.
85 */
86 public function getClockSequenceHex() : string
87 {
88 return $this->fields->getClockSeq()->toString();
89 }
90 /**
91 * @deprecated This method will be removed in 5.0.0. There is no alternative recommendation, so plan accordingly.
92 */
93 public function getNumberConverter() : NumberConverterInterface
94 {
95 return $this->numberConverter;
96 }
97 /**
98 * @deprecated In ramsey/uuid version 5.0.0, this will be removed. It is available at {@see UuidV1::getDateTime()}.
99 *
100 * @return DateTimeImmutable An immutable instance of DateTimeInterface
101 *
102 * @throws UnsupportedOperationException if UUID is not time-based
103 * @throws DateTimeException if DateTime throws an exception/error
104 */
105 public function getDateTime() : DateTimeInterface
106 {
107 if ($this->fields->getVersion() !== 1) {
108 throw new UnsupportedOperationException('Not a time-based UUID');
109 }
110 $time = $this->timeConverter->convertTime($this->fields->getTimestamp());
111 try {
112 return new DateTimeImmutable('@' . $time->getSeconds()->toString() . '.' . str_pad($time->getMicroseconds()->toString(), 6, '0', STR_PAD_LEFT));
113 } catch (Throwable $e) {
114 throw new DateTimeException($e->getMessage(), (int) $e->getCode(), $e);
115 }
116 }
117 /**
118 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
119 *
120 * @return string[]
121 */
122 public function getFieldsHex() : array
123 {
124 return ['time_low' => $this->fields->getTimeLow()->toString(), 'time_mid' => $this->fields->getTimeMid()->toString(), 'time_hi_and_version' => $this->fields->getTimeHiAndVersion()->toString(), 'clock_seq_hi_and_reserved' => $this->fields->getClockSeqHiAndReserved()->toString(), 'clock_seq_low' => $this->fields->getClockSeqLow()->toString(), 'node' => $this->fields->getNode()->toString()];
125 }
126 /**
127 * @deprecated This method will be removed in 5.0.0. There is no direct alternative, but the same information may be
128 * obtained by splitting in half the value returned by {@see UuidInterface::getHex()}.
129 */
130 public function getLeastSignificantBits() : string
131 {
132 $leastSignificantHex = substr($this->getHex()->toString(), 16);
133 return $this->numberConverter->fromHex($leastSignificantHex);
134 }
135 /**
136 * @deprecated This method will be removed in 5.0.0. There is no direct alternative, but the same information may be
137 * obtained by splitting in half the value returned by {@see UuidInterface::getHex()}.
138 */
139 public function getLeastSignificantBitsHex() : string
140 {
141 return substr($this->getHex()->toString(), 16);
142 }
143 /**
144 * @deprecated This method will be removed in 5.0.0. There is no direct alternative, but the same information may be
145 * obtained by splitting in half the value returned by {@see UuidInterface::getHex()}.
146 */
147 public function getMostSignificantBits() : string
148 {
149 $mostSignificantHex = substr($this->getHex()->toString(), 0, 16);
150 return $this->numberConverter->fromHex($mostSignificantHex);
151 }
152 /**
153 * @deprecated This method will be removed in 5.0.0. There is no direct alternative, but the same information may be
154 * obtained by splitting in half the value returned by {@see UuidInterface::getHex()}.
155 */
156 public function getMostSignificantBitsHex() : string
157 {
158 return substr($this->getHex()->toString(), 0, 16);
159 }
160 /**
161 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
162 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
163 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getNode()} and use the arbitrary-precision math library of your
164 * choice to convert it to a string integer.
165 */
166 public function getNode() : string
167 {
168 return $this->numberConverter->fromHex($this->fields->getNode()->toString());
169 }
170 /**
171 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
172 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
173 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getNode()}.
174 */
175 public function getNodeHex() : string
176 {
177 return $this->fields->getNode()->toString();
178 }
179 /**
180 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
181 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
182 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeHiAndVersion()} and use the arbitrary-precision math
183 * library of your choice to convert it to a string integer.
184 */
185 public function getTimeHiAndVersion() : string
186 {
187 return $this->numberConverter->fromHex($this->fields->getTimeHiAndVersion()->toString());
188 }
189 /**
190 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
191 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
192 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeHiAndVersion()}.
193 */
194 public function getTimeHiAndVersionHex() : string
195 {
196 return $this->fields->getTimeHiAndVersion()->toString();
197 }
198 /**
199 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
200 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
201 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeLow()} and use the arbitrary-precision math library of
202 * your choice to convert it to a string integer.
203 */
204 public function getTimeLow() : string
205 {
206 return $this->numberConverter->fromHex($this->fields->getTimeLow()->toString());
207 }
208 /**
209 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
210 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
211 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeLow()}.
212 */
213 public function getTimeLowHex() : string
214 {
215 return $this->fields->getTimeLow()->toString();
216 }
217 /**
218 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
219 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
220 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeMid()} and use the arbitrary-precision math library of
221 * your choice to convert it to a string integer.
222 */
223 public function getTimeMid() : string
224 {
225 return $this->numberConverter->fromHex($this->fields->getTimeMid()->toString());
226 }
227 /**
228 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
229 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
230 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimeMid()}.
231 */
232 public function getTimeMidHex() : string
233 {
234 return $this->fields->getTimeMid()->toString();
235 }
236 /**
237 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
238 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
239 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimestamp()} and use the arbitrary-precision math library of
240 * your choice to convert it to a string integer.
241 */
242 public function getTimestamp() : string
243 {
244 if ($this->fields->getVersion() !== 1) {
245 throw new UnsupportedOperationException('Not a time-based UUID');
246 }
247 return $this->numberConverter->fromHex($this->fields->getTimestamp()->toString());
248 }
249 /**
250 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
251 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
252 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getTimestamp()}.
253 */
254 public function getTimestampHex() : string
255 {
256 if ($this->fields->getVersion() !== 1) {
257 throw new UnsupportedOperationException('Not a time-based UUID');
258 }
259 return $this->fields->getTimestamp()->toString();
260 }
261 /**
262 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
263 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
264 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getVariant()}.
265 */
266 public function getVariant() : ?int
267 {
268 return $this->fields->getVariant();
269 }
270 /**
271 * @deprecated Use {@see UuidInterface::getFields()} to get a {@see \Ramsey\Uuid\Fields\FieldsInterface} instance.
272 * If it is a {@see \Ramsey\Uuid\Rfc4122\FieldsInterface} instance, you may call
273 * {@see \Ramsey\Uuid\Rfc4122\FieldsInterface::getVersion()}.
274 */
275 public function getVersion() : ?int
276 {
277 return $this->fields->getVersion();
278 }
279 }
280