Completed
Push — master ( 4803b3...959101 )
by Frank
03:46
created

AggregateRootId::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace EventSauce\EventSourcing;
4
5
use Ramsey\Uuid\Uuid;
6
use Ramsey\Uuid\UuidInterface;
7
8
final class AggregateRootId
9
{
10
    /**
11
     * @var string
12
     */
13
    private $identifier;
14
15 8
    public function __construct(string $identifier)
16
    {
17 8
        $this->identifier = $identifier;
18 8
    }
19
20 7
    public function toString(): string
21
    {
22 7
        return $this->identifier;
23
    }
24
25 1
    public function toUuid(): UuidInterface
26
    {
27 1
        return Uuid::fromString($this->identifier);
28
    }
29
30 7
    public static function create(): AggregateRootId
31
    {
32 7
        return new AggregateRootId(Uuid::uuid4()->toString());
33
    }
34
}