diff options
author | Mario <mario@mariovavti.com> | 2021-01-13 09:50:53 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2021-01-13 09:50:53 +0000 |
commit | 5eefdc6485b2f6082f6fe5dfd6f1731fae7e3a2a (patch) | |
tree | 7521f4800e393538d19c393c6f495ea2d41cbf5a /vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php | |
parent | 0bc4c7d1a0e4348018e533be600ad1c648fd97fb (diff) | |
parent | 4d2bcbc5837a7d99dc541595ca8087c335242af0 (diff) | |
download | volse-hubzilla-5eefdc6485b2f6082f6fe5dfd6f1731fae7e3a2a.tar.gz volse-hubzilla-5eefdc6485b2f6082f6fe5dfd6f1731fae7e3a2a.tar.bz2 volse-hubzilla-5eefdc6485b2f6082f6fe5dfd6f1731fae7e3a2a.zip |
Merge branch '5.2RC'5.2
Diffstat (limited to 'vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php')
-rw-r--r-- | vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php | 54 |
1 files changed, 20 insertions, 34 deletions
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 @@ <?php + /** * This file is part of the ramsey/uuid library * @@ -7,70 +8,55 @@ * * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com> * @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; } |