FilterHandlerFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WShafer\PSR11MonoLog\Handler;
6
7
use Monolog\Handler\FilterHandler;
8
use WShafer\PSR11MonoLog\HandlerManagerAwareInterface;
9
use WShafer\PSR11MonoLog\HandlerManagerTrait;
10
use WShafer\PSR11MonoLog\FactoryInterface;
11
12
class FilterHandlerFactory implements FactoryInterface, HandlerManagerAwareInterface
13
{
14
    use HandlerManagerTrait;
15
16 1
    public function __invoke(array $options)
17
    {
18 1
        $handler        = $this->getHandlerManager()->get($options['handler']);
19 1
        $minLevelOrList =            $options['minLevelOrList'] ?? null;
20 1
        $maxLevel       =            $options['maxLevel']       ?? null;
21 1
        $bubble         = (bool) ($options['bubble']         ?? true);
22
23 1
        return new FilterHandler(
24 1
            $handler,
0 ignored issues
show
Documentation introduced by
$handler is of type *, but the function expects a callable.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
25 1
            $minLevelOrList,
26 1
            $maxLevel,
27 1
            $bubble
28
        );
29
    }
30
}
31