ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
Factory.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Exception;
24use Ramsey\Uuid\UuidFactory;
25
33{
34 private UuidFactory $uuid_factory;
35
36 public function __construct()
37 {
38 $this->uuid_factory = new UuidFactory();
39 }
40
41 public function uuid4(): Uuid
42 {
43 return new RamseyUuidWrapper($this->uuid_factory->uuid4());
44 }
45
46 public function uuid4AsString(): string
47 {
48 return $this->uuid4()->toString();
49 }
50
56 public function uuid3(Uuid|string $namespace, string $name): Uuid
57 {
58 return new RamseyUuidWrapper(
59 $this->uuid_factory->uuid3($namespace instanceof Uuid ? $namespace->toString() : $namespace, $name)
60 );
61 }
62
63 public function uuid3AsString(Uuid|string $namespace, string $name): string
64 {
65 return $this->uuid3($namespace, $name)->toString();
66 }
67
68 public function fromString(string $uuid): Uuid
69 {
70 return new RamseyUuidWrapper($this->uuid_factory->fromString($uuid));
71 }
72}
fromString(string $uuid)
Definition: Factory.php:68
uuid3AsString(Uuid|string $namespace, string $name)
Definition: Factory.php:63
uuid3(Uuid|string $namespace, string $name)
Name-based UUID (version 3, MD5): the same namespace and name always result in the same UUID.
Definition: Factory.php:56
UuidFactory $uuid_factory
Definition: Factory.php:34
toString()
Converts this UUID into a string representation.