TextTriggerTrait   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 36
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
C trigger() 0 27 7
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