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

ThrowingExceptionMapper::map()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
rs 10
c 1
b 0
f 0
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