TextTriggerTrait::trigger()   B
last analyzed

Complexity

Conditions 7
Paths 6

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
nc 6
nop 2
dl 0
loc 27
rs 8.5546
c 0
b 0
f 0
1
<?php
2
namespace Finder\Logic\Output;
3
4
use Finder\Logic\Analyser;
5
6
/**
7
 * Outputs events information to the console.
8
 *
9
 * @see TriggerableInterface
10
 */
11
trait TextTriggerTrait
12
{
13
    /**
14
     * Output event messages.
15
     *
16
     * @param  integer     $eventType Command class event constant.
17
     * @param  string|null $message   optional message.
18
     * @return void
19
     */
20
    public function trigger($eventType, $message = null)
21
    {
22
        switch ($eventType) {
23
        case Analyser::EVENT_STARTING_ANALYSIS:
24
            $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...
25
            if (!empty($message['ignoredPaths'])) {
26
                $this->cli->out('(ignored paths:)');
27
                foreach ($message['ignoredPaths'] as $ignoredPath) {
0 ignored issues
show
Bug introduced by
The expression $message['ignoredPaths'] of type string is not traversable.
Loading history...
28
                    $this->cli->red("\t" . $ignoredPath);
29
                }
30
            }
31
            break;
32
33
        case Analyser::EVENT_STARTING_TOOL:
34
            $this->cli->inline('Running ' . $message['description'] . '... ');
35
            break;
36
37
        case Analyser::EVENT_FINISHED_TOOL:
38
            $this->cli->out('Done!');
39
            break;
40
41
        case Analyser::EVENT_FINISHED_ANALYSIS:
42
            $this->cli->br();
43
            $this->cli->green('Analysis complete!');
44
            break;
45
        }
46
    }
47
}
48