Completed
Push — master ( 3181c3...80f4ac )
by Juuso
10:53
created

getConstructorParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 10
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 1
crap 2
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
    public function getRequiredParameters(): array
16
    {
17
        return [
18
            'path',
19
        ];
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function getConstructorParameters(array $config): array
26
    {
27
        $filename = \Yii::getAlias($config['path']);
28
        $maxFiles = $config['maxFiles'] ?? 0;
29
        $level = $config['level'] ?? Logger::DEBUG;
30
        $bubble = $config['bubble'] ?? true;
31
        $filePermission = $config['filePermission'] ?? null;
32
        $useLocking = $config['useLocking'] ?? false;
33
34
        return [$filename, $maxFiles, $level, $bubble, $filePermission, $useLocking];
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getConfigurationCallable(array $config): callable
41
    {
42
        return function (RotatingFileHandler $instance) {
43
            return $instance;
44
        };
45
    }
46
}
47