AnnotatesForAggregate   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 23
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAnnotatedRevision() 0 3 1
A getAnnotation() 0 4 1
A getAggregateId() 0 3 1
A getAnnotatedId() 0 3 1
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/event-sourcing project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Daikon\EventSourcing\Aggregate;
10
11
use Daikon\Interop\SupportsAnnotations;
12
13
trait AnnotatesForAggregate
14
{
15
    use SupportsAnnotations;
16
17 4
    public function getAggregateId(): AggregateIdInterface
18
    {
19 4
        return $this->{static::getAnnotatedId()};
20
    }
21
22 4
    private static function getAnnotatedId(): string
23
    {
24 4
        return static::getAnnotation('id');
25
    }
26
27 4
    private static function getAnnotatedRevision(): string
28
    {
29 4
        return static::getAnnotation('rev');
30
    }
31
32 5
    private static function getAnnotation(string $key): string
33
    {
34
        //yield first seen
35 5
        return key(static::inferValueFactories($key));
36
    }
37
}
38