CommandHandlerMiddleware   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 ensureTypeOfMessage() 0 12 2
1
<?php
2
/**
3
 * This file is part of the Cubiche package.
4
 *
5
 * Copyright (c) Cubiche
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Cubiche\Core\Cqrs\Middlewares\Handler;
11
12
use Cubiche\Core\Bus\Middlewares\Handler\MessageHandlerMiddleware;
13
use Cubiche\Core\Cqrs\Command\CommandInterface;
14
15
/**
16
 * CommandHandlerMiddleware class.
17
 *
18
 * @author Ivannis Suárez Jerez <[email protected]>
19
 */
20
class CommandHandlerMiddleware extends MessageHandlerMiddleware
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function ensureTypeOfMessage($message)
26
    {
27
        if (!$message instanceof CommandInterface) {
28
            throw new \InvalidArgumentException(
29
                sprintf(
30
                    'The object must be an instance of %s. Instance of %s given',
31
                    CommandInterface::class,
32
                    get_class($message)
33
                )
34
            );
35
        }
36
    }
37
}
38