Passed
Push — main ( 5561bb...0eda81 )
by Jeroen
02:42 queued 27s
created

UseCaseAttributeRegistry   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 32
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getUseCaseSubscriberMethodForEvent() 0 3 1
A initialize() 0 6 1
A getDomainIdPropertiesForUseCase() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gember\EventSourcing\UseCase;
6
7
use Gember\EventSourcing\Resolver\UseCase\SubscriberMethodForEvent\SubscriberMethodForEventResolver;
8
use Gember\EventSourcing\Resolver\UseCase\DomainIdProperties\DomainIdPropertiesResolver;
9
use Gember\EventSourcing\Resolver\UseCase\DomainIdProperties\UnresolvableDomainIdPropertiesException;
10
11
final class UseCaseAttributeRegistry
12
{
13
    private static DomainIdPropertiesResolver $domainIdsResolver;
14
    private static SubscriberMethodForEventResolver $subscriberMethodsResolver;
15
16 9
    public static function initialize(
17
        DomainIdPropertiesResolver $domainIdsResolver,
18
        SubscriberMethodForEventResolver $subscriberMethodsResolver,
19
    ): void {
20 9
        self::$domainIdsResolver = $domainIdsResolver;
21 9
        self::$subscriberMethodsResolver = $subscriberMethodsResolver;
22
    }
23
24
    /**
25
     * @param class-string<EventSourcedUseCase> $useCaseClassName
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<EventSourcedUseCase> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<EventSourcedUseCase>.
Loading history...
26
     *
27
     * @throws UnresolvableDomainIdPropertiesException
28
     *
29
     * @return list<string>
30
     */
31 3
    public static function getDomainIdPropertiesForUseCase(string $useCaseClassName): array
32
    {
33 3
        return self::$domainIdsResolver->resolve($useCaseClassName);
0 ignored issues
show
Bug Best Practice introduced by
The expression return self::domainIdsRe...olve($useCaseClassName) returns the type array which is incompatible with the documented return type Gember\EventSourcing\UseCase\list.
Loading history...
34
    }
35
36
    /**
37
     * @param class-string<EventSourcedUseCase> $useCaseClassName
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<EventSourcedUseCase> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<EventSourcedUseCase>.
Loading history...
38
     * @param class-string $eventClassName
39
     */
40 8
    public static function getUseCaseSubscriberMethodForEvent(string $useCaseClassName, string $eventClassName): ?string
41
    {
42 8
        return self::$subscriberMethodsResolver->resolve($useCaseClassName, $eventClassName);
43
    }
44
}
45