Logger::getLog()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
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