Completed
Pull Request — master (#63)
by Frank
02:49
created

DummyAggregateRootId   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 33
ccs 9
cts 9
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fromString() 0 3 1
A toString() 0 3 1
A __construct() 0 3 1
A generate() 0 3 1
1
<?php
2
3
namespace EventSauce\EventSourcing\Integration;
4
5
use EventSauce\EventSourcing\AggregateRootId;
6
use Ramsey\Uuid\Uuid;
7
8
class DummyAggregateRootId implements AggregateRootId
9
{
10
    /**
11
     * @var string
12
     */
13
    private $identifier;
14
15 13
    private function __construct(string $identifier)
16
    {
17 13
        $this->identifier = $identifier;
18 13
    }
19
20
    /**
21
     * @return string
22
     */
23 6
    public function toString(): string
24
    {
25 6
        return $this->identifier;
26
    }
27
28
    /**
29
     * @param string $aggregateRootId
30
     *
31
     * @return static
32
     */
33 8
    public static function fromString(string $aggregateRootId): AggregateRootId
34
    {
35 8
        return new static($aggregateRootId);
36
    }
37
38 10
    public static function generate(): AggregateRootId
39
    {
40 10
        return new static(Uuid::uuid4()->toString());
41
    }
42
}
43