Completed
Push — master ( 2ba284...821562 )
by Westin
10:12
created

ElasticSearchHandlerFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 20 1
1
<?php
2
declare(strict_types=1);
3
4
namespace WShafer\PSR11MonoLog\Handler;
5
6
use Monolog\Handler\ElasticSearchHandler;
7
use Monolog\Logger;
8
use WShafer\PSR11MonoLog\ClientTrait;
9
use WShafer\PSR11MonoLog\ContainerAwareInterface;
10
use WShafer\PSR11MonoLog\FactoryInterface;
11
12
class ElasticSearchHandlerFactory implements FactoryInterface, ContainerAwareInterface
13
{
14
    use ClientTrait;
15
16
    public function __invoke(array $options)
17
    {
18
        $client      = $this->getClient($options);
19
        $index       = (string)  ($options['index']       ?? 'monolog');
20
        $type        = (string)  ($options['type']        ?? 'record');
21
        $ignoreError = (boolean) ($options['ignoreError'] ?? false);
22
        $level       = (int)     ($options['level']       ?? Logger::DEBUG);
23
        $bubble      = (boolean) ($options['bubble']      ?? true);
24
25
        return new ElasticSearchHandler(
26
            $client,
27
            [
28
                'index'        => $index,
29
                'type'         => $type,
30
                'ignore_error' => $ignoreError
31
            ],
32
            $level,
33
            $bubble
34
        );
35
    }
36
}
37