Test Setup Failed
Pull Request — master (#15)
by
unknown
08:18
created

StreamHandlerStrategy   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 36
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1
ccs 12
cts 12
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequiredParameters() 0 6 1
A getConstructorParameters() 0 10 1
A getConfigurationCallable() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace bessonov87\Yii2Monolog\CreationStrategies;
6
7
use Monolog\Logger;
8
use Monolog\Handler\StreamHandler;
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