aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/Type/Time.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ramsey/uuid/src/Type/Time.php')
-rw-r--r--vendor/ramsey/uuid/src/Type/Time.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/vendor/ramsey/uuid/src/Type/Time.php b/vendor/ramsey/uuid/src/Type/Time.php
index f6a140f05..dd1b8bc28 100644
--- a/vendor/ramsey/uuid/src/Type/Time.php
+++ b/vendor/ramsey/uuid/src/Type/Time.php
@@ -16,10 +16,12 @@ namespace Ramsey\Uuid\Type;
use Ramsey\Uuid\Exception\UnsupportedOperationException;
use Ramsey\Uuid\Type\Integer as IntegerObject;
+use ValueError;
use stdClass;
use function json_decode;
use function json_encode;
+use function sprintf;
/**
* A value object representing a timestamp
@@ -89,11 +91,23 @@ final class Time implements TypeInterface
}
/**
+ * @return array{seconds: string, microseconds: string}
+ */
+ public function __serialize(): array
+ {
+ return [
+ 'seconds' => $this->getSeconds()->toString(),
+ 'microseconds' => $this->getMicroseconds()->toString(),
+ ];
+ }
+
+ /**
* Constructs the object from a serialized string representation
*
* @param string $serialized The serialized string representation of the object
*
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
+ * @psalm-suppress UnusedMethodCall
*/
public function unserialize($serialized): void
{
@@ -108,4 +122,18 @@ final class Time implements TypeInterface
$this->__construct($time->seconds, $time->microseconds);
}
+
+ /**
+ * @param array{seconds: string, microseconds: string} $data
+ */
+ public function __unserialize(array $data): void
+ {
+ // @codeCoverageIgnoreStart
+ if (!isset($data['seconds']) || !isset($data['microseconds'])) {
+ throw new ValueError(sprintf('%s(): Argument #1 ($data) is invalid', __METHOD__));
+ }
+ // @codeCoverageIgnoreEnd
+
+ $this->__construct($data['seconds'], $data['microseconds']);
+ }
}