AbstractNormalizerFormatterFactory   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 12
c 1
b 0
f 0
dl 0
loc 26
ccs 7
cts 7
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B configureNormalizerFormatter() 0 21 8
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\LaminasMonolog\Factory\Formatter;
6
7
use Arp\LaminasFactory\AbstractFactory;
8
use Monolog\Formatter\NormalizerFormatter;
9
10
abstract class AbstractNormalizerFormatterFactory extends AbstractFactory
11
{
12
    /**
13
     * @param array<mixed> $options
14
     */
15
    protected function configureNormalizerFormatter(NormalizerFormatter $formatter, array $options): void
16
    {
17
        if (isset($options['date_format'])) {
18
            $formatter->setDateFormat($options['date_format']);
19
        }
20
21
        if (isset($options['max_normalize_depth'])) {
22 11
            $formatter->setMaxNormalizeDepth((int)$options['max_normalize_depth']);
23
        }
24 11
25 3
        if (isset($options['max_normalize_item_count'])) {
26
            $formatter->setMaxNormalizeItemCount((int)$options['max_normalize_item_count']);
27
        }
28 11
29 2
        if (isset($options['json_pretty_print'])) {
30
            $formatter->setJsonPrettyPrint((bool)$options['json_pretty_print']);
31
        }
32 11
33 1
        if (!empty($options['json_encode_options']) && is_array($options['json_encode_options'])) {
34
            foreach ($options['json_encode_options'] as $jsonEncodeOption) {
35
                $formatter->addJsonEncodeOption((int)$jsonEncodeOption);
36 11
            }
37 1
        }
38
    }
39
}
40