Deprecate all the fields methods on UuidInterface and Uuid

This commit is contained in:
Ben Ramsey
2020-01-11 22:30:46 -06:00
parent 1c7db1adbd
commit 360261d617
23 changed files with 365 additions and 237 deletions
+13 -4
View File
@@ -17,6 +17,7 @@ namespace Ramsey\Uuid\Codec;
use Ramsey\Uuid\Builder\UuidBuilderInterface;
use Ramsey\Uuid\Exception\InvalidArgumentException;
use Ramsey\Uuid\Exception\InvalidUuidStringException;
use Ramsey\Uuid\Rfc4122\FieldsInterface;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
@@ -47,11 +48,21 @@ class StringCodec implements CodecInterface
*/
public function encode(UuidInterface $uuid): string
{
$fields = array_values($uuid->getFieldsHex());
/** @var FieldsInterface $fields */
$fields = $uuid->getFields();
$components = [
$fields->getTimeLow()->toString(),
$fields->getTimeMid()->toString(),
$fields->getTimeHiAndVersion()->toString(),
$fields->getClockSeqHiAndReserved()->toString(),
$fields->getClockSeqLow()->toString(),
$fields->getNode()->toString(),
];
return vsprintf(
'%08s-%04s-%04s-%02s%02s-%012s',
$fields
$components
);
}
@@ -152,8 +163,6 @@ class StringCodec implements CodecInterface
/**
* Returns the fields that make up this UUID
*
* @see \Ramsey\Uuid\UuidInterface::getFieldsHex()
*
* @param string[] $components An array of hexadecimal strings representing
* the fields of an RFC 4122 UUID
*