Completed
Push — master ( 758742...ec9771 )
by Zach
02:36
created

Logger::write()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Yarak\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
        $this->log[] = $message;
22
    }
23
24
    /**
25
     * Return the log array.
26
     *
27
     * @param int $index
28
     *
29
     * @return array
30
     */
31
    public function getLog($index = null)
32
    {
33
        if (is_null($index)) {
34
            return $this->log;
35
        }
36
37
        return $this->log[$index];
38
    }
39
40
    /**
41
     * Return true if log contains message.
42
     *
43
     * @param string $message
44
     *
45
     * @return bool
46
     */
47
    public function hasMessage($message)
48
    {
49
        return in_array($message, $this->getLog());
50
    }
51
}
52