RotatingFileHandlerStrategy   A
last analyzed

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\Logger;
8
9
class RotatingFileHandlerStrategy implements CreationStrategyInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14 1
    public function getRequiredParameters(): array
15
    {
16
        return [
17 1
            'path',
18
        ];
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 3
    public function getConstructorParameters(array $config): array
25
    {
26 3
        $filename = \Yii::getAlias($config['path']);
27 3
        $maxFiles = $config['maxFiles'] ?? 0;
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 [$filename, $maxFiles, $level, $bubble, $filePermission, $useLocking];
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function getConfigurationCallable(array $config): callable
40
    {
41 2
        return $config['configure'] ?? function ($instance) {
42 1
            return $instance;
43 2
        };
44
    }
45
}
46