JsonFormatterFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 9
c 1
b 0
f 0
dl 0
loc 20
ccs 2
cts 2
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\LaminasMonolog\Factory\Formatter;
6
7
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
8
use Monolog\Formatter\JsonFormatter;
9
use Psr\Container\ContainerExceptionInterface;
10
use Psr\Container\ContainerInterface;
11
12
final class JsonFormatterFactory extends AbstractNormalizerFormatterFactory
13
{
14
    /**
15
     * @throws ServiceNotCreatedException
16
     * @throws ContainerExceptionInterface
17
     */
18
    public function __invoke(ContainerInterface $container, string $requestedName, array $options = null): JsonFormatter
19
    {
20
        $options = $options ?? $this->getServiceOptions($container, $requestedName);
21
22
        $formatter = new JsonFormatter(
23
            $options['batch_mode'] ?? JsonFormatter::BATCH_MODE_JSON,
24
            $options['append_new_line'] ?? true,
25
            $options['ignore_empty_context_and_extra'] ?? false,
26
            $options['include_stack_traces'] ?? false,
27
        );
28 5
29
        $this->configureNormalizerFormatter($formatter, $options);
30 5
31
        return $formatter;
32 5
    }
33
}
34