Passed
Push — main ( b2f07c...c5252d )
by Breno
02:07
created

ThrowingExceptionMapper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A map() 0 8 2
1
<?php
2
declare(strict_types=1);
3
4
namespace OniBus\Handler\ClassMethod\Mapper;
5
6
use OniBus\Exception\UnresolvableMessageException;
7
use OniBus\Handler\ClassMethod\ClassMethodMapper;
8
use OniBus\Message;
9
10
/**
11
 * Decorator
12
 */
13
class ThrowingExceptionMapper implements ClassMethodMapper
14
{
15
    /**
16
     * @var ClassMethodMapper
17
     */
18
    private $mapper;
19
20
    public function __construct(ClassMethodMapper $mapper)
21
    {
22
        $this->mapper = $mapper;
23
    }
24
25
    /**
26
     * @inheritDoc
27
     */
28
    public function map(Message $message): array
29
    {
30
        $mapped = $this->mapper->map($message);
31
        if (empty($mapped)) {
32
            throw UnresolvableMessageException::message($message);
33
        }
34
35
        return $mapped;
36
    }
37
}
38