ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CertificateId.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use InvalidArgumentException;
24
26{
27 private const UUID_LENGTH = 36;
28 private const UUID_SEPARATOR_COUNT = 4;
29
30 private readonly string $certificate_id;
31
32 public function __construct(string $certificate_id)
33 {
34 if ($certificate_id === '') {
35 throw new InvalidArgumentException('certificate_id cannot be empty.');
36 }
37
38 if (strlen($certificate_id) !== self::UUID_LENGTH) {
39 throw new InvalidArgumentException(sprintf(
40 'certificate_id must be a valid UUID. UUID must be %s characters long.',
41 self::UUID_LENGTH
42 ));
43 }
44
45 if (substr_count($certificate_id, '-') !== 4) {
46 throw new InvalidArgumentException(sprintf(
47 'certificate_id must be a valid UUID. UUID must contain %s "-" characters.',
48 self::UUID_SEPARATOR_COUNT
49 ));
50 }
51 $this->certificate_id = $certificate_id;
52 }
53
54 public function asString(): string
55 {
57 }
58}