LineFormatterFactory::__invoke()   A
last analyzed

Complexity

Conditions 4
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 15
ccs 2
cts 2
cp 1
rs 9.9666
cc 4
nc 1
nop 3
crap 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