Completed
Push — master ( 4803b3...959101 )
by Frank
03:46
created

UpcasterStub::canUpcast()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace EventSauce\EventSourcing\Integration\Upcasting;
4
5
use EventSauce\EventSourcing\Serialization\EventType;
6
use EventSauce\EventSourcing\Upcasting\DelegatableUpcaster;
7
use Generator;
8
9
class UpcasterStub implements DelegatableUpcaster
10
{
11 1
    public function canUpcast(string $type, int $version): bool
12
    {
13 1
        return $this->type() === $type && $version < 1;
14
    }
15
16 1
    public function upcast(string $type, int $version, array $payload): Generator
17
    {
18 1
        $payload['data']['property'] = 'upcasted';
19 1
        $payload['version'] = 1;
20
21 1
        yield $payload;
22 1
    }
23
24 1
    public function type(): string
25
    {
26 1
        return EventType::fromClassName(UpcastedEventStub::class)->toEventName();
27
    }
28
}