GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#7)
by Fábio Tadeu da
02:12
created

MapBased   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
eloc 10
dl 0
loc 34
rs 10
c 0
b 0
f 0
ccs 0
cts 16
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A convert() 0 15 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dsantang\DomainEventsDoctrine\Outbox;
6
7
use Dsantang\DomainEvents\DomainEvent;
8
use function get_class;
9
10
final class MapBased extends EventsHandler
11
{
12
    /** @var converter[] */
13
    private $conversionMap;
14
15
    /**
16
     * @param converter[] $conversionMap
17
     */
18
    public function __construct(OutboxMappedSuperclass $outboxMappedSuperclass, array $conversionMap)
19
    {
20
        $this->outboxMappedSuperclass = $outboxMappedSuperclass;
21
        $this->conversionMap          = $conversionMap;
22
    }
23
24
    /**
25
     * @param DomainEvent[] $domainEvents
26
     *
27
     * @return OutboxEntry[]
28
     */
29
    public function convert(DomainEvent ...$domainEvents) : array
30
    {
31
        $outboxEntries = [];
32
33
        foreach ($domainEvents as $domainEvent) {
34
            if (! isset($this->conversionMap[get_class($domainEvent)])) {
35
                continue;
36
            }
37
38
            $converterClass = $this->conversionMap[get_class($domainEvent)];
39
40
            $outboxEntries[] = $converterClass->convert($domainEvent);
41
        }
42
43
        return $outboxEntries;
44
    }
45
}
46