ElasticaHandlerFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 25
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 20 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