Passed
Push — master ( c94b6d...d25cd5 )
by Nikolaos
02:58
created

MemoryLogger   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 31
ccs 7
cts 11
cp 0.6364
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A log() 0 7 2
A getMessages() 0 3 1
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 3
    public function getMessages()
41
    {
42 3
        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 3
    public function log($level, $message, array $context = [])
53
    {
54 3
        $replace = [];
55 3
        foreach ($context as $key => $val) {
56 2
            $replace['{' . $key . '}'] = $val;
57
        }
58 3
        $this->messages[] = strtr($message, $replace);
59 3
    }
60
}
61