Passed
Push — master ( dbfb37...74a6ed )
by Frank
46s queued 13s
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
declare(strict_types=1);
4
5
namespace EventSauce\EventSourcing\Integration;
6
7
use EventSauce\EventSourcing\AggregateRootId;
8
use Ramsey\Uuid\Uuid;
9
10
class DummyAggregateRootId implements AggregateRootId
11
{
12
    /**
13
     * @var string
14
     */
15
    private $identifier;
16
17 13
    private function __construct(string $identifier)
18
    {
19 13
        $this->identifier = $identifier;
20 13
    }
21
22
    /**
23
     * @return string
24
     */
25 6
    public function toString(): string
26
    {
27 6
        return $this->identifier;
28
    }
29
30
    /**
31
     * @param string $aggregateRootId
32
     *
33
     * @return static
34
     */
35 8
    public static function fromString(string $aggregateRootId): AggregateRootId
36
    {
37 8
        return new static($aggregateRootId);
38
    }
39
40 10
    public static function generate(): AggregateRootId
41
    {
42 10
        return new static(Uuid::uuid4()->toString());
43
    }
44
}
45