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

getConstructorParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
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\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