aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/uuid/src/Type/Integer.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ramsey/uuid/src/Type/Integer.php')
-rw-r--r--vendor/ramsey/uuid/src/Type/Integer.php35
1 files changed, 33 insertions, 2 deletions
diff --git a/vendor/ramsey/uuid/src/Type/Integer.php b/vendor/ramsey/uuid/src/Type/Integer.php
index 05d420a85..7690f6cd8 100644
--- a/vendor/ramsey/uuid/src/Type/Integer.php
+++ b/vendor/ramsey/uuid/src/Type/Integer.php
@@ -15,9 +15,11 @@ declare(strict_types=1);
namespace Ramsey\Uuid\Type;
use Ramsey\Uuid\Exception\InvalidArgumentException;
+use ValueError;
use function ctype_digit;
use function ltrim;
+use function sprintf;
use function strpos;
use function substr;
@@ -36,7 +38,7 @@ use function substr;
final class Integer implements NumberInterface
{
/**
- * @var string
+ * @psalm-var numeric-string
*/
private $value;
@@ -80,7 +82,10 @@ final class Integer implements NumberInterface
$this->isNegative = true;
}
- $this->value = $value;
+ /** @psalm-var numeric-string $numericValue */
+ $numericValue = $value;
+
+ $this->value = $numericValue;
}
public function isNegative(): bool
@@ -88,6 +93,9 @@ final class Integer implements NumberInterface
return $this->isNegative;
}
+ /**
+ * @psalm-return numeric-string
+ */
public function toString(): string
{
return $this->value;
@@ -109,14 +117,37 @@ final class Integer 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']);
+ }
}