Passed
Pull Request — master (#29)
by Frank
02:45
created

ConstructingEventSerializer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A unserializePayload() 0 4 1
A serializeEvent() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EventSauce\EventSourcing\Serialization;
6
7
class ConstructingEventSerializer implements EventSerializer
8
{
9
    /**
10
     * @param SerializableEvent $event
11
     * @return array
12
     */
13 6
    public function serializeEvent(object $event): array
14
    {
15 6
        return $event->toPayload();
16
    }
17
18 7
    public function unserializePayload(string $className, array $payload): object
19
    {
20
        /** @var SerializableEvent $className */
21 7
        return $className::fromPayload($payload);
22
    }
23
}
24