mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-16 16:17:43 +03:00
Add support for PHP 8.1
This commit is contained in:
@@ -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
|
||||
@@ -88,6 +90,17 @@ final class Time implements TypeInterface
|
||||
return (string) json_encode($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*
|
||||
@@ -109,4 +122,16 @@ final class Time implements TypeInterface
|
||||
|
||||
$this->__construct($time->seconds, $time->microseconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{seconds: string, microseconds: string} $data
|
||||
*/
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
if (!isset($data['seconds']) || !isset($data['microseconds'])) {
|
||||
throw new ValueError(sprintf('%s(): Argument #1 ($data) is invalid', __METHOD__));
|
||||
}
|
||||
|
||||
$this->__construct($data['seconds'], $data['microseconds']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user