-
-
Notifications
You must be signed in to change notification settings - Fork 466
Expand file tree
/
Copy pathEventId.php
More file actions
49 lines (41 loc) · 967 Bytes
/
EventId.php
File metadata and controls
49 lines (41 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
namespace Sentry;
use Sentry\Util\SentryUid;
/**
* This class represents an event ID.
*
* @author Stefano Arlandini <sarlandini@alice.it>
*/
final class EventId
{
/**
* @var string The ID
*/
private $value;
/**
* Class constructor.
*
* @param string $value The ID
*/
public function __construct(string $value)
{
if (!preg_match('/^[a-f0-9]{32}$/i', $value)) {
throw new \InvalidArgumentException('The $value argument must be a 32 characters long hexadecimal string.');
}
$this->value = $value;
}
/**
* Generates a new event ID.
*
* @copyright Matt Farina MIT License https://github.com/lootils/uuid/blob/master/LICENSE
*/
public static function generate(): self
{
return new self(SentryUid::generate());
}
public function __toString(): string
{
return $this->value;
}
}