LineFormatterFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 15 4
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\LineFormatter;
9
use Psr\Container\ContainerExceptionInterface;
10
use Psr\Container\ContainerInterface;
11
12
final class LineFormatterFactory extends AbstractNormalizerFormatterFactory
13
{
14
    /**
15
     * @throws ServiceNotCreatedException
16
     * @throws ContainerExceptionInterface
17
     */
18
    public function __invoke(ContainerInterface $container, string $requestedName, array $options = null): LineFormatter
19
    {
20
        $options = $options ?? $this->getServiceOptions($container, $requestedName);
21
22
        $formatter = new LineFormatter(
23
            $options['format'] ?? null,
24
            $options['date_format'] ?? null,
25
            isset($options['allow_inline_line_breaks']) && $options['allow_inline_line_breaks'],
26
            isset($options['ignore_empty_context_and_extra']) && $options['ignore_empty_context_and_extra'],
27
            isset($options['include_stack_traces']) && $options['include_stack_traces']
28
        );
29
30 4
        $this->configureNormalizerFormatter($formatter, $options);
31
32 4
        return $formatter;
33
    }
34
}
35