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

ThrowingExceptionMapper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
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