aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/Type/Decimal.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ramsey/uuid/src/Type/Decimal.php')
-rw-r--r--vendor/ramsey/uuid/src/Type/Decimal.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/vendor/ramsey/uuid/src/Type/Decimal.php b/vendor/ramsey/uuid/src/Type/Decimal.php
index 5ba886535..10f93845b 100644
--- a/vendor/ramsey/uuid/src/Type/Decimal.php
+++ b/vendor/ramsey/uuid/src/Type/Decimal.php
@@ -15,8 +15,10 @@ declare(strict_types=1);
namespace Ramsey\Uuid\Type;
use Ramsey\Uuid\Exception\InvalidArgumentException;
+use ValueError;
use function is_numeric;
+use function sprintf;
/**
* A value object representing a decimal
@@ -99,14 +101,37 @@ final class Decimal implements NumberInterface
}
/**
+ * @return array{string: string}
+ */
+ public function __serialize(): array
+ {
+ return ['string' => $this->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
{
$this->__construct($serialized);
}
+
+ /**
+ * @param array{string: string} $data
+ */
+ public function __unserialize(array $data): void
+ {
+ // @codeCoverageIgnoreStart
+ if (!isset($data['string'])) {
+ throw new ValueError(sprintf('%s(): Argument #1 ($data) is invalid', __METHOD__));
+ }
+ // @codeCoverageIgnoreEnd
+
+ $this->unserialize($data['string']);
+ }
}