Completed
Push — master ( 52b242...112fdc )
by Thomas
17s queued 11s
created

LoggerStack::getInstance()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the ekino Drupal Debug project.
7
 *
8
 * (c) ekino
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Ekino\Drupal\Debug\Logger;
15
16
use Monolog\Handler\StreamHandler;
17
use Monolog\Logger;
18
19
final class LoggerStack
20
{
21
    /**
22
     * @var Logger[]
23
     */
24
    private static $instances = array();
25
26 2
    public static function getInstance(string $channel, string $filePath): Logger
27
    {
28 2
        if (!isset(self::$instances[$key = $channel.$filePath])) {
29 2
            self::$instances[$key] = new Logger($channel, array(
30 2
                new StreamHandler($filePath),
31
            ));
32
        }
33
34 2
        return self::$instances[$key];
35
    }
36
}
37