Completed
Push — master ( 1092bf...021295 )
by Westin
01:44
created

CouchDBHandlerFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 16

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.2
c 0
b 0
f 0
cc 1
eloc 16
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace WShafer\PSR11MonoLog\Handler;
5
6
use Monolog\Handler\CouchDBHandler;
7
use Monolog\Logger;
8
use WShafer\PSR11MonoLog\FactoryInterface;
9
10
class CouchDBHandlerFactory implements FactoryInterface
11
{
12 1
    public function __invoke(array $options)
13
    {
14 1
        $host     = (string)  ($options['host']     ?? 'localhost');
15 1
        $port     = (int)     ($options['port']     ?? 5984);
16 1
        $dbname   = (string)  ($options['port']     ?? 'logger');
17 1
        $userName = (string)  ($options['username'] ?? '');
18 1
        $password = (string)  ($options['password'] ?? '');
19 1
        $level    = (int)     ($options['level']    ?? Logger::DEBUG);
20 1
        $bubble   = (boolean) ($options['bubble']   ?? true);
21
22 1
        return new CouchDBHandler(
23
            [
24 1
                'host'     => $host,
25 1
                'port'     => $port,
26 1
                'dbname'   => $dbname,
27 1
                'username' => $userName,
28 1
                'password' => $password
29
            ],
30 1
            $level,
31 1
            $bubble
32
        );
33
    }
34
}
35