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

AggregateRootId   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 77.78%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 27
ccs 7
cts 9
cp 0.7778
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 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
}