Passed
Push — master ( dbfb37...74a6ed )
by Frank
46s queued 13s
created

DummyAggregateRootId::generate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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 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