DumpLogMiddleware::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
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\Middleware;
13
14
use League\Tactician\Middleware;
15
use LineMob\Core\Command\AbstractCommand;
16
use Symfony\Component\VarDumper\VarDumper;
17
18
/**
19
 * @author Ishmael Doss <[email protected]>
20
 */
21
class DumpLogMiddleware implements Middleware
22
{
23
    private $isDebug;
24
25
    public function __construct($isDebug)
26
    {
27
        $this->isDebug = $isDebug;
28
    }
29
30
    /**
31
     * @param AbstractCommand $command
32
     *
33
     * {@inheritdoc}
34
     */
35
    public function execute($command, callable $next)
36
    {
37
        // dev only
38
        if ($this->isDebug && $command->logs) {
39
            VarDumper::dump($command->logs);
40
        }
41
42
        return $next($command);
43
    }
44
}
45