Passed
Push — master ( 5d9d84...47a8c2 )
by Mr
02:22
created

AnnotatesForAggregate::getAnnotatedId()   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
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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;
0 ignored issues
show
Bug introduced by
The type Daikon\Interop\SupportsAnnotations was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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));
0 ignored issues
show
Bug Best Practice introduced by
The expression return key(static::inferValueFactories($key)) could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
36
    }
37
}
38