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.php37
1 files changed, 13 insertions, 24 deletions
diff --git a/vendor/ramsey/uuid/src/Type/Time.php b/vendor/ramsey/uuid/src/Type/Time.php
index dd1b8bc28..745b5ccab 100644
--- a/vendor/ramsey/uuid/src/Type/Time.php
+++ b/vendor/ramsey/uuid/src/Type/Time.php
@@ -17,7 +17,6 @@ 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;
@@ -34,22 +33,13 @@ use function sprintf;
*/
final class Time implements TypeInterface
{
- /**
- * @var IntegerObject
- */
- private $seconds;
-
- /**
- * @var IntegerObject
- */
- private $microseconds;
+ private IntegerObject $seconds;
+ private IntegerObject $microseconds;
- /**
- * @param mixed $seconds
- * @param mixed $microseconds
- */
- public function __construct($seconds, $microseconds = 0)
- {
+ public function __construct(
+ float | int | string | IntegerObject $seconds,
+ float | int | string | IntegerObject $microseconds = 0,
+ ) {
$this->seconds = new IntegerObject($seconds);
$this->microseconds = new IntegerObject($microseconds);
}
@@ -104,27 +94,26 @@ final class Time implements TypeInterface
/**
* Constructs the object from a serialized string representation
*
- * @param string $serialized The serialized string representation of the object
+ * @param string $data The serialized string representation of the object
*
- * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
* @psalm-suppress UnusedMethodCall
*/
- public function unserialize($serialized): void
+ public function unserialize(string $data): void
{
- /** @var stdClass $time */
- $time = json_decode($serialized);
+ /** @var array{seconds?: int|float|string, microseconds?: int|float|string} $time */
+ $time = json_decode($data, true);
- if (!isset($time->seconds) || !isset($time->microseconds)) {
+ if (!isset($time['seconds']) || !isset($time['microseconds'])) {
throw new UnsupportedOperationException(
'Attempted to unserialize an invalid value'
);
}
- $this->__construct($time->seconds, $time->microseconds);
+ $this->__construct($time['seconds'], $time['microseconds']);
}
/**
- * @param array{seconds: string, microseconds: string} $data
+ * @param array{seconds?: string, microseconds?: string} $data
*/
public function __unserialize(array $data): void
{