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

AggregateRootId   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 27
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toString() 0 4 1
A toUuid() 0 4 1
A create() 0 4 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
}