Passed
Push — master ( 65eb9d...9eadd3 )
by Juuso
03:44
created

RotatingFileHandlerStrategy   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequiredParameters() 0 6 1
A getConstructorParameters() 0 11 1
A getConfigurationCallable() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace leinonen\Yii2Monolog\CreationStrategies;
6
7
use Monolog\Handler\RotatingFileHandler;
8
use Monolog\Logger;
9
10
class RotatingFileHandlerStrategy 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
        $filename = \Yii::getAlias($config['path']);
28 3
        $maxFiles = $config['maxFiles'] ?? 0;
29 3
        $level = $config['level'] ?? Logger::DEBUG;
30 3
        $bubble = $config['bubble'] ?? true;
31 3
        $filePermission = $config['filePermission'] ?? null;
32 3
        $useLocking = $config['useLocking'] ?? false;
33
34 3
        return [$filename, $maxFiles, $level, $bubble, $filePermission, $useLocking];
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getConfigurationCallable(array $config): callable
41
    {
42 2
        return $config['configure'] ?? function ($instance) {
43 1
            return $instance;
44 2
        };
45
    }
46
}
47