TextTriggerTrait::trigger()   C
last analyzed

Complexity

Conditions 7
Paths 6

Size

Total Lines 27
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 6.7272
c 0
b 0
f 0
cc 7
eloc 19
nc 6
nop 2
1
<?php
2
namespace phphound\output;
3
4
use phphound\Analyser;
5
6
/**
7
 * Outputs events information to the console.
8
 * @see TriggerableInterface
9
 */
10
trait TextTriggerTrait
11
{
12
    /**
13
     * Output event messages.
14
     * @param integer $eventType Command class event constant.
15
     * @param string|null $message optional message.
16
     * @return void
17
     */
18
    public function trigger($eventType, $message = null)
19
    {
20
        switch ($eventType) {
21
            case Analyser::EVENT_STARTING_ANALYSIS:
22
                $this->cli->green('Starting analysis');
0 ignored issues
show
Bug introduced by
The property cli does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
23
                if (!empty($message['ignoredPaths'])) {
24
                    $this->cli->out('(ignored paths:)');
25
                    foreach ($message['ignoredPaths'] as $ignoredPath) {
0 ignored issues
show
Bug introduced by
The expression $message['ignoredPaths'] of type string is not traversable.
Loading history...
26
                        $this->cli->red("\t" . $ignoredPath);
27
                    }
28
                }
29
                break;
30
31
            case Analyser::EVENT_STARTING_TOOL:
32
                $this->cli->inline('Running ' . $message['description'] . '... ');
33
                break;
34
35
            case Analyser::EVENT_FINISHED_TOOL:
36
                $this->cli->out('Done!');
37
                break;
38
39
            case Analyser::EVENT_FINISHED_ANALYSIS:
40
                $this->cli->br();
41
                $this->cli->green('Analysis complete!');
42
                break;
43
        }
44
    }
45
}
46