FromMessageNamedResolver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 12 2
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Cubiche\Core\Bus\Middlewares\Handler\Resolver\NameOfMessage;
13
14
use Cubiche\Core\Bus\MessageInterface;
15
use Cubiche\Core\Bus\MessageNamedInterface;
16
17
/**
18
 * FromMessageNamedResolver class.
19
 *
20
 * @author Ivannis Suárez Jerez <[email protected]>
21
 */
22
class FromMessageNamedResolver implements ResolverInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function resolve(MessageInterface $message)
28
    {
29
        if ($message instanceof MessageNamedInterface) {
30
            return $message->named();
31
        }
32
33
        throw new \InvalidArgumentException(sprintf(
34
            'The object of type %s should implement the %s interface',
35
            get_class($message),
36
            MessageNamedInterface::class
37
        ));
38
    }
39
}
40