ZendMonitorHandlerFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 72.22 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 13
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 6 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace WShafer\PSR11MonoLog\Handler;
6
7
use Monolog\Handler\MissingExtensionException;
8
use Monolog\Handler\ZendMonitorHandler;
9
use Monolog\Logger;
10
use WShafer\PSR11MonoLog\FactoryInterface;
11
12
/**
13
 * @codeCoverageIgnore
14
 *
15
 * No Zend Server available to test against
16
 */
17 View Code Duplication
class ZendMonitorHandlerFactory implements FactoryInterface
18
{
19
    /**
20
     * @param array $options
21
     * @return ZendMonitorHandler
22
     * @throws MissingExtensionException
23
     */
24
    public function __invoke(array $options)
25
    {
26
        $level  = (int)     ($options['level']  ?? Logger::DEBUG);
27
        $bubble = (bool) ($options['bubble'] ?? true);
28
29
        return new ZendMonitorHandler(
30
            $level,
31
            $bubble
32
        );
33
    }
34
}
35