Passed
Push — master ( a1a5b3...2e461e )
by Tomasz
01:31
created

Uuid::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
/**
3
 *
4
 * This file is part of the Aggrego.
5
 * (c) Tomasz Kunicki <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 */
11
12
declare(strict_types = 1);
13
14
namespace Aggrego\EventConsumer\Event;
15
16
use Assert\Assertion;
17
use TimiTao\ValueObject\Utils\StringValueObject;
18
19
class Uuid extends StringValueObject
20
{
21
    public function __construct(string $value)
22
    {
23
        Assertion::regex(
24
            $value,
25
            '/^[0-9A-F]{8}-[0-9A-F]{4}-[1-5][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i',
26
            'Incorrect UUID format: ' . $value
27
        );
28
        parent::__construct(self::class, $value);
29
    }
30
}
31