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

CouchDBHandlerFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 25
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 22 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