@@ 19-54 (lines=36) @@ | ||
16 | /** |
|
17 | * UUID identifier for APN |
|
18 | */ |
|
19 | class ApnId |
|
20 | { |
|
21 | /** |
|
22 | * @var string |
|
23 | */ |
|
24 | private $value; |
|
25 | ||
26 | /** |
|
27 | * Constructor. |
|
28 | * |
|
29 | * @param string $value |
|
30 | * |
|
31 | * @throws \InvalidArgumentException |
|
32 | */ |
|
33 | public function __construct(string $value) |
|
34 | { |
|
35 | if (!\preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/', $value)) { |
|
36 | throw new \InvalidArgumentException(\sprintf( |
|
37 | 'Invalid UUID identifier "%s".', |
|
38 | $value |
|
39 | )); |
|
40 | } |
|
41 | ||
42 | $this->value = $value; |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * Get value |
|
47 | * |
|
48 | * @return string |
|
49 | */ |
|
50 | public function getValue(): string |
|
51 | { |
|
52 | return $this->value; |
|
53 | } |
|
54 | } |
|
55 |
@@ 19-62 (lines=44) @@ | ||
16 | /** |
|
17 | * Device token model |
|
18 | */ |
|
19 | class DeviceToken |
|
20 | { |
|
21 | /** |
|
22 | * @var string |
|
23 | */ |
|
24 | private $value; |
|
25 | ||
26 | /** |
|
27 | * Constructor. |
|
28 | * |
|
29 | * @param string $token |
|
30 | * |
|
31 | * @throws \InvalidArgumentException |
|
32 | */ |
|
33 | public function __construct(string $token) |
|
34 | { |
|
35 | if (!\preg_match('/^[0-9a-fA-F]{64}$/', $token)) { |
|
36 | throw new \InvalidArgumentException(sprintf( |
|
37 | 'Invalid device token "%s".', |
|
38 | $token |
|
39 | )); |
|
40 | } |
|
41 | ||
42 | $this->value = $token; |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * Get token value |
|
47 | * |
|
48 | * @return string |
|
49 | */ |
|
50 | public function getValue(): string |
|
51 | { |
|
52 | return $this->value; |
|
53 | } |
|
54 | ||
55 | /** |
|
56 | * {@inheritdoc} |
|
57 | */ |
|
58 | public function __toString() |
|
59 | { |
|
60 | return $this->value; |
|
61 | } |
|
62 | } |
|
63 |