Upgrade framework

This commit is contained in:
2023-11-14 16:54:35 +01:00
parent 1648a5cd42
commit 4fcf6fffcc
10548 changed files with 693138 additions and 466698 deletions

View File

@@ -1,4 +1,5 @@
<?php
/**
* This file is part of the ramsey/uuid library
*
@@ -7,47 +8,60 @@
*
* @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\Builder;
use Ramsey\Uuid\Codec\CodecInterface;
use Ramsey\Uuid\Converter\NumberConverterInterface;
use Ramsey\Uuid\Converter\Time\DegradedTimeConverter;
use Ramsey\Uuid\Converter\TimeConverterInterface;
use Ramsey\Uuid\DegradedUuid;
use Ramsey\Uuid\Rfc4122\Fields as Rfc4122Fields;
use Ramsey\Uuid\UuidInterface;
/**
* DegradedUuidBuilder builds instances of DegradedUuid
* @deprecated DegradedUuid instances are no longer necessary to support 32-bit
* systems. Transition to {@see DefaultUuidBuilder}.
*
* @psalm-immutable
*/
class DegradedUuidBuilder implements UuidBuilderInterface
{
/**
* @var NumberConverterInterface
*/
private $converter;
private TimeConverterInterface $timeConverter;
/**
* Constructs the DegradedUuidBuilder
*
* @param NumberConverterInterface $converter The number converter to use when constructing the DegradedUuid
* @param NumberConverterInterface $numberConverter The number converter to
* use when constructing the DegradedUuid
* @param TimeConverterInterface|null $timeConverter The time converter to use
* for converting timestamps extracted from a UUID to Unix timestamps
*/
public function __construct(NumberConverterInterface $converter)
{
$this->converter = $converter;
public function __construct(
private NumberConverterInterface $numberConverter,
?TimeConverterInterface $timeConverter = null
) {
$this->timeConverter = $timeConverter ?: new DegradedTimeConverter();
}
/**
* Builds a DegradedUuid
* Builds and returns a DegradedUuid
*
* @param CodecInterface $codec The codec to use for building this DegradedUuid
* @param array $fields An array of fields from which to construct the DegradedUuid;
* see {@see \Ramsey\Uuid\UuidInterface::getFieldsHex()} for array structure.
* @return DegradedUuid
* @param CodecInterface $codec The codec to use for building this DegradedUuid instance
* @param string $bytes The byte string from which to construct a UUID
*
* @return DegradedUuid The DegradedUuidBuild returns an instance of Ramsey\Uuid\DegradedUuid
*
* @psalm-pure
*/
public function build(CodecInterface $codec, array $fields)
public function build(CodecInterface $codec, string $bytes): UuidInterface
{
return new DegradedUuid($fields, $this->converter, $codec);
return new DegradedUuid(
new Rfc4122Fields($bytes),
$this->numberConverter,
$codec,
$this->timeConverter
);
}
}