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

HandlerComposite::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 1
b 0
f 0
cc 3
nc 3
nop 0
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
}