Skip to content

Commit c307d8f

Browse files
committed
[Uid] refactor MockUuidFactory to inherit from UuidFactory and keep API consistent
1 parent c7fb676 commit c307d8f

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/Symfony/Component/Uid/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ CHANGELOG
55
---
66

77
* Add microsecond precision to UUIDv7
8-
* Add `MockUuidFactory` and `UuidFactoryInterface` to allow deterministic and mockable UUID generation for testing purposes
8+
* Add `MockUuidFactory` to allow deterministic and mockable UUID generation for testing purposes
99

1010
7.3
1111
---

src/Symfony/Component/Uid/Factory/MockUuidFactory.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ public function __construct(
3030
Uuid|string|null $nameBasedNamespace = null,
3131
) {
3232
parent::__construct($defaultClass, $timeBasedClass, $nameBasedClass, $randomBasedClass, $timeBasedNode, $nameBasedNamespace);
33-
$this->validateDefaultClass($defaultClass);
33+
if (!is_subclass_of($this->defaultClass, Uuid::class)) {
34+
throw new \InvalidArgumentException(\sprintf('The class "%s" must be a subclass of "%s".', $this->defaultClass, Uuid::class));
35+
}
3436
$this->sequence = \is_array($uuids) ? new \ArrayIterator($uuids) : new \IteratorIterator($uuids);
3537
}
3638

@@ -44,11 +46,4 @@ public function create(): Uuid
4446

4547
return $this->defaultClass::fromString($uuid);
4648
}
47-
48-
private function validateDefaultClass(string $class): void
49-
{
50-
if (!is_subclass_of($class, Uuid::class)) {
51-
throw new \InvalidArgumentException(\sprintf('The class "%s" must be a subclass of "%s".', $class, Uuid::class));
52-
}
53-
}
5449
}

0 commit comments

Comments
 (0)