Passed
Push — master ( 12e656...9e9627 )
by Nikolaos
02:33
created

MemoryLogger::log()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 3
dl 0
loc 7
ccs 0
cts 7
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the Phalcon Framework.
5
 *
6
 * (c) Phalcon Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 *
11
 * Implementation of this file has been influenced by AtlasPHP
12
 *
13
 * @link    https://github.com/atlasphp/Atlas.Pdo
14
 * @license https://github.com/atlasphp/Atlas.Pdo/blob/1.x/LICENSE.md
15
 */
16
17
declare(strict_types=1);
18
19
namespace Phalcon\DataMapper\Pdo\Profiler;
20
21
use Psr\Log\AbstractLogger;
22
23
/**
24
 * A naive memory-based logger.
25
 *
26
 * @property array $messages
27
 */
28
class MemoryLogger extends AbstractLogger
29
{
30
    /**
31
     * @var array
32
     */
33
    protected $messages = [];
34
35
    /**
36
     * Returns the logged messages.
37
     *
38
     * @return array
39
     */
40
    public function getMessages()
41
    {
42
        return $this->messages;
43
    }
44
45
    /**
46
     * Logs a message.
47
     *
48
     * @param mixed  $level
49
     * @param string $message
50
     * @param array  $context
51
     */
52
    public function log($level, $message, array $context = [])
53
    {
54
        $replace = [];
55
        foreach ($context as $key => $val) {
56
            $replace['{' . $key . '}'] = $val;
57
        }
58
        $this->messages[] = strtr($message, $replace);
59
    }
60
}
61