Completed
Pull Request — master (#66)
by Frank
07:06 queued 04:59
created

DummyAggregateRootId::generate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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
    private function __construct(string $identifier)
18
    {
19
        $this->identifier = $identifier;
20
    }
21
22
    /**
23
     * @return string
24
     */
25
    public function toString(): string
26
    {
27
        return $this->identifier;
28
    }
29
30
    /**
31
     * @param string $aggregateRootId
32
     *
33
     * @return static
34
     */
35
    public static function fromString(string $aggregateRootId): AggregateRootId
36
    {
37
        return new static($aggregateRootId);
38
    }
39
40
    public static function generate(): AggregateRootId
41
    {
42
        return new static(Uuid::uuid4()->toString());
43
    }
44
}
45