SyslogUdpHandlerFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 14
cts 14
cp 1
rs 9.6666
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\SyslogUdpHandler;
8
use Monolog\Logger;
9
use WShafer\PSR11MonoLog\FactoryInterface;
10
11
class SyslogUdpHandlerFactory implements FactoryInterface
12
{
13 1
    public function __invoke(array $options)
14
    {
15 1
        $host     = (string)  ($options['host']     ?? '');
16 1
        $port     = (int)     ($options['host']     ?? 514);
17 1
        $facility = (int)     ($options['facility'] ?? LOG_USER);
18 1
        $level    = (int)     ($options['level']    ?? Logger::DEBUG);
19 1
        $bubble   = (bool) ($options['bubble']   ?? true);
20 1
        $ident    = (string)  ($options['ident']    ?? 'php');
21
22 1
        return new SyslogUdpHandler(
23 1
            $host,
24 1
            $port,
25 1
            $facility,
26 1
            $level,
27 1
            $bubble,
28 1
            $ident
29
        );
30
    }
31
}
32