Passed
Pull Request — master (#54)
by Frank
04:59
created

DummyAggregateRootId::toString()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
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
namespace EventSauce\EventSourcing\Integration\TestingAggregates;
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 9
    private function __construct(string $identifier)
16
    {
17 9
        $this->identifier = $identifier;
18 9
    }
19
20
    /**
21
     * @return string
22
     */
23 4
    public function toString(): string
24
    {
25 4
        return $this->identifier;
26
    }
27
28
    /**
29
     * @param string $aggregateRootId
30
     *
31
     * @return static
32
     */
33 4
    public static function fromString(string $aggregateRootId): AggregateRootId
34
    {
35 4
        return new static($aggregateRootId);
36
    }
37
38 9
    public static function generate(): AggregateRootId
39
    {
40 9
        return new static(Uuid::uuid4()->toString());
41
    }
42
}
43