diff options
author | Mario <mario@mariovavti.com> | 2020-11-27 08:04:00 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2020-11-27 08:04:00 +0000 |
commit | f4bb7bcbff3770387c2fecfa91ce4a60b916a474 (patch) | |
tree | ea007e664d435f1f3d63c87bfe1600484d2bd46c /vendor/ramsey/uuid/src/Provider/Time | |
parent | 07e5b8295ea9d342f66d8119d88bd58124b548e6 (diff) | |
download | volse-hubzilla-f4bb7bcbff3770387c2fecfa91ce4a60b916a474.tar.gz volse-hubzilla-f4bb7bcbff3770387c2fecfa91ce4a60b916a474.tar.bz2 volse-hubzilla-f4bb7bcbff3770387c2fecfa91ce4a60b916a474.zip |
update composer libs
Diffstat (limited to 'vendor/ramsey/uuid/src/Provider/Time')
-rw-r--r-- | vendor/ramsey/uuid/src/Provider/Time/FixedTimeProvider.php | 54 | ||||
-rw-r--r-- | vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php | 22 |
2 files changed, 31 insertions, 45 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; } diff --git a/vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php b/vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php index 6442985fa..3a1e09cb4 100644 --- a/vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php +++ b/vendor/ramsey/uuid/src/Provider/Time/SystemTimeProvider.php @@ -1,4 +1,5 @@ <?php + /** * This file is part of the ramsey/uuid library * @@ -7,27 +8,26 @@ * * @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 Ramsey\Uuid\Provider\TimeProviderInterface; +use Ramsey\Uuid\Type\Time; + +use function gettimeofday; /** - * SystemTimeProvider uses built-in PHP functions to provide the time + * SystemTimeProvider retrieves the current time using built-in PHP functions */ class SystemTimeProvider implements TimeProviderInterface { - /** - * Returns a timestamp array - * - * @return int[] Array containing `sec` and `usec` components of a timestamp - */ - public function currentTime() + public function getTime(): Time { - return gettimeofday(); + $time = gettimeofday(); + + return new Time($time['sec'], $time['usec']); } } |