Skip to content

Commit 9e50ff9

Browse files
committed
UUID class
1 parent a9fc742 commit 9e50ff9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/ConstantContact/UUID.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace PHPFUI\ConstantContact;
4+
5+
/**
6+
* Simple UUID class for JSON output
7+
*/
8+
class UUID
9+
{
10+
public function __construct(private string $uuid)
11+
{
12+
if (! preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', $uuid))
13+
{
14+
throw new \PHPFUI\ConstantContact\Exception\InvalidValue($uuid . ' is not a valid UUID');
15+
}
16+
}
17+
18+
public function __toString() : string
19+
{
20+
return $this->uuid;
21+
}
22+
}

0 commit comments

Comments
 (0)