Logger   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 55
rs 10
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A write() 0 4 2
A getLog() 0 7 2
A clearLog() 0 3 1
A hasMessage() 0 3 1
1
<?php
2
3
namespace Artisanize\Output;
4
5
class Logger extends Output
6
{
7
    /**
8
     * Log of received messages.
9
     *
10
     * @var array
11
     */
12
    protected $log = [];
13
14
    /**
15
     * Write a message.
16
     *
17
     * @param string $message
18
     */
19
    public function write($message)
20
    {
21
        if ($this->verbosity) {
22
            $this->log[] = $message;
23
        }
24
    }
25
26
    /**
27
     * Return the log array.
28
     *
29
     * @param int $index
30
     *
31
     * @return array
32
     */
33
    public function getLog($index = null)
34
    {
35
        if (is_null($index)) {
36
            return $this->log;
37
        }
38
39
        return $this->log[$index];
40
    }
41
42
    /**
43
     * Return true if log contains message.
44
     *
45
     * @param string $message
46
     *
47
     * @return bool
48
     */
49
    public function hasMessage($message)
50
    {
51
        return in_array($message, $this->getLog());
52
    }
53
54
    /**
55
     * Clear the log.
56
     */
57
    public function clearLog()
58
    {
59
        $this->log = [];
60
    }
61
}
62