Completed
Push — develop ( 686594...b5844e )
by Florent
03:11
created

FakeLogger::critical()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
/*
4
 * The MIT License (MIT)
5
 *
6
 * Copyright (c) 2014-2016 Spomky-Labs
7
 *
8
 * This software may be modified and distributed under the terms
9
 * of the MIT license.  See the LICENSE file for details.
10
 */
11
12
namespace Jose\Test\Stub;
13
14
use Psr\Log\LoggerInterface;
15
16
class FakeLogger implements LoggerInterface
17
{
18
    /**
19
     * @var array
20
     */
21
    private $messages = [];
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function emergency($message, array $context = [])
27
    {
28
        $this->log('emergency', $message, $context);
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function alert($message, array $context = [])
35
    {
36
        $this->log('alert', $message, $context);
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function critical($message, array $context = [])
43
    {
44
        $this->log('critical', $message, $context);
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function error($message, array $context = [])
51
    {
52
        $this->log('error', $message, $context);
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function warning($message, array $context = [])
59
    {
60
        $this->log('warning', $message, $context);
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function notice($message, array $context = [])
67
    {
68
        $this->log('notice', $message, $context);
69
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74
    public function info($message, array $context = [])
75
    {
76
        $this->log('info', $message, $context);
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82
    public function debug($message, array $context = [])
83
    {
84
        $this->log('debug', $message, $context);
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function log($level, $message, array $context = [])
91
    {
92
        $this->messages[] = [
93
            'timestamp' => microtime(true),
94
            'level'     => $level,
95
            'message'   => $message,
96
            'context'   => $context,
97
        ];
98
    }
99
100
    /**
101
     * @return array
102
     */
103
    public function getMessages()
104
    {
105
        return $this->messages;
106
    }
107
}
108