ThrowableHandlerAggregate   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 6
c 1
b 0
f 0
dl 0
loc 32
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A attach() 0 3 1
A handleThrowable() 0 4 2
1
<?php
2
3
/**
4
 * This file is part of coisa/error-handler.
5
 *
6
 * (c) Felipe Sayão Lobato Abreu <[email protected]>
7
 *
8
 * This source file is subject to the license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
declare(strict_types=1);
13
14
namespace CoiSA\ErrorHandler\Handler;
15
16
/**
17
 * Class ThrowableHandlerAggregate
18
 *
19
 * @package CoiSA\ErrorHandler\Handler
20
 */
21
final class ThrowableHandlerAggregate implements ThrowableHandlerInterface
22
{
23
    /**
24
     * @var ThrowableHandlerInterface[]
25
     */
26
    private $handlers;
27
28
    /**
29
     * ThrowableHandlerAggregate constructor.
30
     *
31
     * @param ThrowableHandlerInterface ...$throwableHandlers
32
     */
33 33
    public function __construct(ThrowableHandlerInterface ...$throwableHandlers)
34
    {
35 33
        $this->handlers = $throwableHandlers;
36 33
    }
37
38
    /**
39
     * @param ThrowableHandlerInterface $throwableHandler
40
     */
41 31
    public function attach(ThrowableHandlerInterface $throwableHandler): void
42
    {
43 31
        $this->handlers[] = $throwableHandler;
44 31
    }
45
46
    /**
47
     * @param \Throwable $throwable
48
     */
49 2
    public function handleThrowable(\Throwable $throwable): void
50
    {
51 2
        foreach ($this->handlers as $handler) {
52 2
            $handler->handleThrowable($throwable);
53
        }
54 2
    }
55
}
56