Debugger   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 52
ccs 19
cts 19
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A commandNotRun() 0 6 2
A commandRun() 0 6 2
A log() 0 6 2
1
<?php namespace Indatus\Dispatcher;
2
3
use Indatus\Dispatcher\Scheduling\ScheduledCommandInterface;
4
use Symfony\Component\Console\Output\OutputInterface;
5
6
/**
7
 * @copyright   2014 Indatus
8
 * @package Indatus\Dispatcher
9
 */
10
11
class Debugger
12
{
13
    /** @var \Symfony\Component\Console\Output\OutputInterface */
14
    protected $output;
15
16
    /** @var \Indatus\Dispatcher\OptionReader */
17
    protected $optionReader;
18
19 4
    public function __construct(OptionReader $optionReader, OutputInterface $output)
20
    {
21 4
        $this->output = $output;
22 4
        $this->optionReader = $optionReader;
23 4
    }
24
25
    /**
26
     * Indicate why a command was not run
27
     *
28
     * @param ScheduledCommandInterface $command
29
     * @param                           $reason
30
     */
31 1
    public function commandNotRun(ScheduledCommandInterface $command, $reason)
32
    {
33 1
        if ($this->optionReader->isDebugMode()) {
34 1
            $this->output->writeln('     <comment>'.$command->getName().'</comment>: '.$reason);
35 1
        }
36 1
    }
37
38
    /**
39
     * Indicate why a command has run
40
     *
41
     * @param ScheduledCommandInterface $command
42
     * @param                           $runCommand
43
     */
44 1
    public function commandRun(ScheduledCommandInterface $command, $runCommand)
45
    {
46 1
        if ($this->optionReader->isDebugMode()) {
47 1
            $this->output->writeln('     <info>'.$command->getName().'</info>: '.$runCommand);
48 1
        }
49 1
    }
50
51
    /**
52
     * Log plain text
53
     *
54
     * @param $message
55
     */
56 1
    public function log($message)
57
    {
58 1
        if ($this->optionReader->isDebugMode()) {
59 1
            $this->output->writeln($message);
60 1
        }
61 1
    }
62
}
63