Completed
Pull Request — master (#29)
by Frank
03:09
created

ConstructingEventSerializer::serializeEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EventSauce\EventSourcing\Serialization;
6
7
use function assert;
8
use function get_class;
9
use LogicException;
10
11
class ConstructingEventSerializer implements EventSerializer
12
{
13
    /**
14
     * @param SerializableEvent $event
15
     * @return array
16
     */
17 6
    public function serializeEvent(object $event): array
18
    {
19 6
        return $event->toPayload();
20
    }
21
22 7
    public function unserializePayload(string $className, array $payload): object
23
    {
24
        /** @var SerializableEvent $className */
25 7
        return $className::fromPayload($payload);
26
    }
27
}
28