Passed
Pull Request — master (#1)
by Alex
08:35
created

MemoryPeakUsageProcessorFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 16 3
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\MemoryPeakUsageProcessor;
10
use Psr\Container\ContainerInterface;
11
12
/**
13
 * @author  Alex Patterson <[email protected]>
14
 * @package Arp\LaminasMonolog\Factory\Processor
15
 */
16
final class MemoryPeakUsageProcessorFactory extends AbstractFactory
17
{
18
    /**
19
     * @param ContainerInterface $container
20
     * @param string             $requestedName
21
     * @param array<mixed>|null  $options
22
     *
23
     * @return MemoryPeakUsageProcessor
24
     *
25
     * @throws ServiceNotCreatedException
26
     */
27
    public function __invoke(
28
        ContainerInterface $container,
29
        string $requestedName,
30
        array $options = null
31
    ): MemoryPeakUsageProcessor {
32
        $options = $options ?? $this->getServiceOptions($container, $requestedName);
33
34
        $realUsage = isset($options['real_usage'])
35
            ? (bool)$options['real_usage']
36
            : true;
37
38
        $useFormatting = isset($options['use_formatting'])
39
            ? (bool)$options['use_formatting']
40
            : true;
41
42
        return new MemoryPeakUsageProcessor($realUsage, $useFormatting);
43
    }
44
}
45