Completed
Push — master ( 6037ea...469bd2 )
by Frank
08:42 queued 05:01
created

AggregateRootId::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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 6
    public function __construct(string $identifier)
16
    {
17 6
        $this->identifier = $identifier;
18 6
    }
19
20 6
    public function toString(): string
21
    {
22 6
        return $this->identifier;
23
    }
24
25
    public function toUuid(): UuidInterface
26
    {
27
        return Uuid::fromString($this->identifier);
28
    }
29
30 6
    public static function create(): AggregateRootId
31
    {
32 6
        return new AggregateRootId(Uuid::uuid4()->toString());
33
    }
34
}