PsrLogMessageProcessorFactory::__invoke()   A
last analyzed

Complexity

Conditions 4
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
ccs 0
cts 1
cp 0
rs 10
cc 4
nc 1
nop 3
crap 20
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\LaminasMonolog\Factory\Processor;
6
7
use Arp\LaminasFactory\AbstractFactory;
8
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
9
use Monolog\Processor\PsrLogMessageProcessor;
10
use Psr\Container\ContainerExceptionInterface;
11
use Psr\Container\ContainerInterface;
12
13
final class PsrLogMessageProcessorFactory extends AbstractFactory
14
{
15
    /**
16
     * @throws ServiceNotCreatedException
17
     * @throws ContainerExceptionInterface
18
     */
19
    public function __invoke(
20
        ContainerInterface $container,
21
        string $requestedName,
22
        array $options = null
23
    ): PsrLogMessageProcessor {
24
        $options = $options ?? $this->getServiceOptions($container, $requestedName);
25
26
        return new PsrLogMessageProcessor(
27
            (isset($options['date_format']) && is_string($options['date_format']))
28
                ? $options['date_format']
29
                : null,
30
            isset($options['remove_used_context_fields']) && $options['remove_used_context_fields']
31
        );
32
    }
33
}
34