Passed
Push — master ( 42303c...a9e041 )
by Dispositif
02:43
created

HandlerComposite   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
dl 0
loc 19
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 7 3
1
<?php
2
/*
3
 * This file is part of dispositif/wikibot application (@github)
4
 * 2019-2023 © Philippe M./Irønie  <[email protected]>
5
 * For the full copyright and MIT license information, view the license file.
6
 */
7
8
declare(strict_types=1);
9
10
namespace App\Domain\WikiOptimizer\Handlers;
11
12
use LogicException;
13
14
class HandlerComposite implements OptimizeHandlerInterface
15
{
16
    /**
17
     * @var OptimizeHandlerInterface[]
18
     */
19
    private $handlers;
20
21
    public function __construct(array $handlers)
22
    {
23
        $this->handlers = $handlers;
24
    }
25
26
    public function handle()
27
    {
28
        foreach ($this->handlers as $handler) {
29
            if (!$handler instanceof OptimizeHandlerInterface) {
30
                throw new LogicException("Handler $handler must implement OptimizeHandlerInterface");
31
            }
32
            $handler->handle();
33
        }
34
    }
35
}