Passed
Pull Request — master (#1)
by Alex
02:54
created

NullHandlerFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arp\LaminasMonolog\Factory\Handler;
6
7
use Arp\LaminasFactory\AbstractFactory;
8
use Laminas\ServiceManager\Exception\ServiceNotCreatedException;
9
use Monolog\Handler\NullHandler;
10
use Monolog\Logger;
11
use Psr\Container\ContainerExceptionInterface;
12
use Psr\Container\ContainerInterface;
13
14
/**
15
 * @author  Alex Patterson <[email protected]>
16
 * @package Arp\LaminasMonolog\Factory\Handler
17
 */
18
final class NullHandlerFactory extends AbstractFactory
19
{
20
    /**
21
     * @param ContainerInterface $container
22
     * @param string             $requestedName
23
     * @param array<mixed>|null  $options
24
     *
25
     * @return NullHandler
26
     *
27
     * @throws ServiceNotCreatedException
28
     * @throws ContainerExceptionInterface
29
     */
30 2
    public function __invoke(ContainerInterface $container, string $requestedName, array $options = null): NullHandler
31
    {
32 2
        $options = $options ?? $this->getServiceOptions($container, $requestedName);
33
34 2
        $level = $options['level'] ?? Logger::DEBUG;
35
36 2
        return new NullHandler($level);
37
    }
38
}
39