Passed
Pull Request — master (#14)
by
03:17
created

SwitchingMiddleware::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the LineMob package.
5
 *
6
 * (c) Ishmael Doss <[email protected]>
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 LineMob\Core\Mocky\Switcher;
13
14
use League\Tactician\Middleware;
15
use LineMob\Core\Command\AbstractCommand;
16
use LineMob\Core\Template\TextTemplate;
17
18
/**
19
 * @author Ishmael Doss <[email protected]>
20
 */
21
class SwitchingMiddleware implements Middleware
22
{
23
    /**
24
     * @param AbstractCommand $command
25
     *
26
     * {@inheritdoc}
27
     */
28
    public function execute($command, callable $next)
29
    {
30
        $cmd = new SwitchedCommand();
31
        $cmd->message = new TextTemplate();
32
        $cmd->message->text = 'SwitchingMiddleware';
33
        $cmd->input = $command->input;
34
35
        $command['switchTo'] = $cmd;
36
37
        return $next($command);
38
    }
39
}
40