ElasticaHandlerFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 14
cts 14
cp 1
rs 9.6
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WShafer\PSR11MonoLog\Handler;
6
7
use Monolog\Handler\ElasticaHandler;
8
use Monolog\Logger;
9
use WShafer\PSR11MonoLog\ContainerAwareInterface;
10
use WShafer\PSR11MonoLog\FactoryInterface;
11
use WShafer\PSR11MonoLog\ServiceTrait;
12
13
class ElasticaHandlerFactory implements FactoryInterface, ContainerAwareInterface
14
{
15
    use ServiceTrait;
16
17 1
    public function __invoke(array $options)
18
    {
19 1
        $client      = $this->getService($options['client'] ?? null);
20 1
        $index       = (string)  ($options['index']       ?? 'monolog');
21 1
        $type        = (string)  ($options['type']        ?? 'record');
22 1
        $ignoreError = (bool) ($options['ignoreError'] ?? false);
23 1
        $level       = (int)     ($options['level']       ?? Logger::DEBUG);
24 1
        $bubble      = (bool) ($options['bubble']      ?? true);
25
26 1
        return new ElasticaHandler(
27 1
            $client,
28
            [
29 1
                'index'        => $index,
30 1
                'type'         => $type,
31 1
                'ignore_error' => $ignoreError
32
            ],
33 1
            $level,
34 1
            $bubble
35
        );
36
    }
37
}
38