mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-14 15:56:48 +03:00
Add support for PHP 8.1
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -114,6 +116,14 @@ final class Integer implements NumberInterface
|
||||
return $this->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{string: string}
|
||||
*/
|
||||
public function __serialize(): array
|
||||
{
|
||||
return ['string' => $this->toString()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the object from a serialized string representation
|
||||
*
|
||||
@@ -126,4 +136,16 @@ final class Integer implements NumberInterface
|
||||
{
|
||||
$this->__construct($serialized);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{string: string} $data
|
||||
*/
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
if (!isset($data['string'])) {
|
||||
throw new ValueError(sprintf('%s(): Argument #1 ($data) is invalid', __METHOD__));
|
||||
}
|
||||
|
||||
$this->unserialize($data['string']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user