LogmaticFormatterFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 22
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 19 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WShafer\PSR11MonoLog\Formatter;
6
7
use Monolog\Formatter\JsonFormatter;
8
use Monolog\Formatter\LogmaticFormatter;
9
use WShafer\PSR11MonoLog\FactoryInterface;
10
11
class LogmaticFormatterFactory implements FactoryInterface
12
{
13 1
    public function __invoke(array $options)
14
    {
15 1
        $batchMode     = (int)     ($options['batchMode']     ?? JsonFormatter::BATCH_MODE_JSON);
16 1
        $appendNewline = (bool) ($options['appendNewline'] ?? true);
17 1
        $hostmane      = (string)  ($options['hostname'] ?? '');
18 1
        $appName       = (string)  ($options['appName'] ?? '');
19
20 1
        $formatter = new LogmaticFormatter($batchMode, $appendNewline);
21
22 1
        if (!empty($hostmane)) {
23 1
            $formatter->setHostname($hostmane);
24
        }
25
26 1
        if (!empty($appName)) {
27 1
            $formatter->setAppname($appName);
28
        }
29
30 1
        return $formatter;
31
    }
32
}
33