CouchDBHandlerFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 16
cts 16
cp 1
rs 9.568
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\CouchDBHandler;
8
use Monolog\Logger;
9
use WShafer\PSR11MonoLog\FactoryInterface;
10
11
class CouchDBHandlerFactory implements FactoryInterface
12
{
13 1
    public function __invoke(array $options)
14
    {
15 1
        $host     = (string)  ($options['host']     ?? 'localhost');
16 1
        $port     = (int)     ($options['port']     ?? 5984);
17 1
        $dbname   = (string)  ($options['port']     ?? 'logger');
18 1
        $userName = (string)  ($options['username'] ?? '');
19 1
        $password = (string)  ($options['password'] ?? '');
20 1
        $level    = (int)     ($options['level']    ?? Logger::DEBUG);
21 1
        $bubble   = (bool) ($options['bubble']   ?? true);
22
23 1
        return new CouchDBHandler(
24
            [
25 1
                'host'     => $host,
26 1
                'port'     => $port,
27 1
                'dbname'   => $dbname,
28 1
                'username' => $userName,
29 1
                'password' => $password
30
            ],
31 1
            $level,
32 1
            $bubble
33
        );
34
    }
35
}
36