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

DummyAggregateRootId::__construct()   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 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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