Completed
Push — master ( 0645ff...69fe3d )
by Juuso
03:39
created

StreamHandlerStrategy::getConfigurationCallable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace leinonen\Yii2Monolog\CreationStrategies;
6
7
use Monolog\Handler\StreamHandler;
8
use Monolog\Logger;
9
10
class StreamHandlerStrategy implements CreationStrategyInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 1
    public function getRequiredParameters(): array
16
    {
17
        return [
18 1
            'path',
19
        ];
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25 3
    public function getConstructorParameters(array $config): array
26
    {
27 3
        $stream = \Yii::getAlias($config['path']);
28 3
        $level = $config['level'] ?? Logger::DEBUG;
29 3
        $bubble = $config['bubble'] ?? true;
30 3
        $filePermission = $config['filePermission'] ?? null;
31 3
        $useLocking = $config['useLocking'] ?? false;
32
33 3
        return [$stream, $level, $bubble, $filePermission, $useLocking];
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function getConfigurationCallable(array $config): callable
40
    {
41 1
        return function (StreamHandler $instance) {
42 1
            return $instance;
43 1
        };
44
    }
45
}
46