CascadeHandler   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 8
c 3
b 0
f 0
lcom 0
cbo 3
dl 0
loc 49
ccs 0
cts 19
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A isHandling() 0 14 4
A write() 0 8 3
1
<?php
2
3
namespace Oqq\Minc\Log\Handler;
4
5
use Oqq\Minc\Log\Record;
6
7
/**
8
 * @author Eric Braun <[email protected]>
9
 */
10
class CascadeHandler extends AbstractHandler implements HandlerContainerInterface
11
{
12
    use HandlerContainerTrait;
13
14
    /**
15
     * @param HandlerInterface[] $handlers
16
     * @param int $level
17
     * @param bool $pass
18
     */
19
    public function __construct(
20
        array $handlers,
21
        $level = HandlerInterface::DEFAULT_LEVEL,
22
        $pass = HandlerInterface::DEFAULT_PASS
23
    ) {
24
        parent::__construct($level, $pass);
25
26
        $this->setHandlers($handlers);
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32
    public function isHandling(Record $record)
33
    {
34
        if (!parent::isHandling($record)) {
35
            return false;
36
        }
37
38
        foreach ($this->getHandlers() as $handler) {
39
            if ($handler->isHandling($record)) {
40
                return true;
41
            }
42
        }
43
44
        return false;
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    protected function write(Record $record)
51
    {
52
        foreach ($this->getHandlers() as $handler) {
53
            if ($handler->isHandling($record)) {
54
                $handler->handle($record);
55
            }
56
        }
57
    }
58
}
59