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

HtmlFormatterFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 1
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\HtmlFormatter;
9
use Psr\Container\ContainerExceptionInterface;
10
use Psr\Container\ContainerInterface;
11
12
/**
13
 * @author  Alex Patterson <[email protected]>
14
 * @package Arp\LaminasMonolog\Factory\Formatter
15
 */
16
final class HtmlFormatterFactory extends AbstractNormalizerFormatterFactory
17
{
18
    /**
19
     * @param ContainerInterface $container
20
     * @param string             $requestedName
21
     * @param array<mixed>|null  $options
22
     *
23
     * @return HtmlFormatter
24
     *
25
     * @throws ServiceNotCreatedException
26
     * @throws ContainerExceptionInterface
27
     */
28 2
    public function __invoke(ContainerInterface $container, string $requestedName, array $options = null): HtmlFormatter
29
    {
30 2
        $options = $options ?? $this->getServiceOptions($container, $requestedName);
31
32 2
        $formatter = new HtmlFormatter(
33 2
            $options['date_format'] ?? null
34
        );
35
36 2
        $this->configureNormalizerFormatter($formatter, $options);
37 2
        return $formatter;
38
    }
39
}
40