Skip to content

Commit

Permalink
Merge pull request #20 from teamleadercrm/feature/support-ramsey-uuid…
Browse files Browse the repository at this point in the history
…-4.5.x

Support Ramsey UUID 4.5.x
  • Loading branch information
StephenBeirlaen authored Oct 25, 2022
2 parents 5852108 + 6321fff commit 7accd8a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "teamleadercrm/uuidifier",
"require": {
"ramsey/uuid": ">=4.2 <4.5",
"ramsey/uuid": ">=4.2 <4.6",
"symfony/console": "^3.1|^4.0|^5.0|^6.0"
},
"autoload": {
Expand Down
11 changes: 7 additions & 4 deletions src/Nonstandard/VersionZeroFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@
use Ramsey\Uuid\Exception\InvalidArgumentException;
use Ramsey\Uuid\Fields\SerializableFieldsTrait;
use Ramsey\Uuid\Rfc4122\FieldsInterface;
use Ramsey\Uuid\Rfc4122\MaxTrait;
use Ramsey\Uuid\Rfc4122\NilTrait;
use Ramsey\Uuid\Rfc4122\VariantTrait;
use Ramsey\Uuid\Rfc4122\VersionTrait;
use Ramsey\Uuid\Type\Hexadecimal;
use Ramsey\Uuid\Uuid;

final class VersionZeroFields implements FieldsInterface
{
use MaxTrait;
use NilTrait;
use SerializableFieldsTrait;
use VariantTrait;
use VersionTrait;

private string $bytes;

Expand Down Expand Up @@ -105,7 +109,7 @@ public function getTimestamp(): Hexadecimal

public function getVersion(): ?int
{
if ($this->isNil()) {
if ($this->isMax() || $this->isNil()) {
return null;
}

Expand All @@ -114,10 +118,9 @@ public function getVersion(): ?int
return (int) $parts[4] >> 12;
}


private function isCorrectVariant(): bool
{
if ($this->isNil()) {
if ($this->isMax() || $this->isNil()) {
return true;
}

Expand All @@ -126,7 +129,7 @@ private function isCorrectVariant(): bool

private function isCorrectVersion(): bool
{
if ($this->isNil()) {
if ($this->isMax() || $this->isNil()) {
return true;
}

Expand Down

0 comments on commit 7accd8a

Please sign in to comment.