From f4bb7bcbff3770387c2fecfa91ce4a60b916a474 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 27 Nov 2020 08:04:00 +0000 Subject: update composer libs --- .../uuid/src/Provider/Time/FixedTimeProvider.php | 54 ++++++++-------------- 1 file changed, 20 insertions(+), 34 deletions(-) (limited to 'vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php') diff --git a/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php b/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php index 79a9d04e0..b8bfd7215 100644 --- a/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php +++ b/vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php @@ -1,4 +1,5 @@ * @license http://opensource.org/licenses/MIT MIT - * @link https://benramsey.com/projects/ramsey-uuid/ Documentation - * @link https://packagist.org/packages/ramsey/uuid Packagist - * @link https://github.com/ramsey/uuid GitHub */ +declare(strict_types=1); + namespace Ramsey\Uuid\Provider\Time; -use InvalidArgumentException; use Ramsey\Uuid\Provider\TimeProviderInterface; +use Ramsey\Uuid\Type\Integer as IntegerObject; +use Ramsey\Uuid\Type\Time; /** - * FixedTimeProvider uses an previously-generated timestamp to provide the time + * FixedTimeProvider uses an known time to provide the time * - * This provider allows the use of a previously-generated timestamp, such as one - * stored in a database, when creating version 1 UUIDs. + * This provider allows the use of a previously-generated, or known, time + * when generating time-based UUIDs. */ class FixedTimeProvider implements TimeProviderInterface { /** - * @var int[] Array containing `sec` and `usec` components of a timestamp + * @var Time */ private $fixedTime; - /** - * Constructs a `FixedTimeProvider` using the provided `$timestamp` - * - * @param int[] Array containing `sec` and `usec` components of a timestamp - * @throws InvalidArgumentException if the `$timestamp` does not contain `sec` or `usec` components - */ - public function __construct(array $timestamp) + public function __construct(Time $time) { - if (!array_key_exists('sec', $timestamp) || !array_key_exists('usec', $timestamp)) { - throw new InvalidArgumentException('Array must contain sec and usec keys.'); - } - - $this->fixedTime = $timestamp; + $this->fixedTime = $time; } /** - * Sets the `usec` component of the timestamp + * Sets the `usec` component of the time * - * @param int $value The `usec` value to set + * @param int|string|IntegerObject $value The `usec` value to set */ - public function setUsec($value) + public function setUsec($value): void { - $this->fixedTime['usec'] = $value; + $this->fixedTime = new Time($this->fixedTime->getSeconds(), $value); } /** - * Sets the `sec` component of the timestamp + * Sets the `sec` component of the time * - * @param int $value The `sec` value to set + * @param int|string|IntegerObject $value The `sec` value to set */ - public function setSec($value) + public function setSec($value): void { - $this->fixedTime['sec'] = $value; + $this->fixedTime = new Time($value, $this->fixedTime->getMicroseconds()); } - /** - * Returns a timestamp array - * - * @return int[] Array containing `sec` and `usec` components of a timestamp - */ - public function currentTime() + public function getTime(): Time { return $this->fixedTime; } -- cgit v1.2.3