Passed
Pull Request — master (#84)
by Frank
10:50
created

UpcasterChain   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A upcast() 0 7 2
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EventSauce\EventSourcing\Upcasting;
6
7
class UpcasterChain implements Upcaster
8
{
9
    /**
10
     * @var Upcaster[]
11
     */
12
    private array $upcasters;
13
14
    public function __construct(Upcaster ...$upcasters)
15
    {
16
        $this->upcasters = $upcasters;
17
    }
18
19
    public function upcast(array $message): array
20
    {
21
        foreach ($this->upcasters as $upcaster) {
22
            $message = $upcaster->upcast($message);
23
        }
24
25
        return $message;
26
    }
27
}
28