Security update for permissions_by_term
[yaffs-website] / vendor / behat / behat / src / Behat / Testwork / Output / Node / EventListener / ChainEventListener.php
1 <?php
2
3 /*
4  * This file is part of the Behat.
5  * (c) Konstantin Kudryashov <ever.zet@gmail.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 namespace Behat\Testwork\Output\Node\EventListener;
12
13 use ArrayIterator;
14 use Behat\Testwork\Output\Formatter;
15 use Countable;
16 use IteratorAggregate;
17 use Symfony\Component\EventDispatcher\Event;
18
19 /**
20  * Used to compose formatter event listeners.
21  *
22  * @author Konstantin Kudryashov <ever.zet@gmail.com>
23  */
24 class ChainEventListener implements EventListener, Countable, IteratorAggregate
25 {
26     /**
27      * @var EventListener[]
28      */
29     private $listeners;
30
31     /**
32      * Initializes collection.
33      *
34      * @param EventListener[] $listeners
35      */
36     public function __construct(array $listeners)
37     {
38         $this->listeners = $listeners;
39     }
40
41     /**
42      * {@inheritdoc}
43      */
44     public function listenEvent(Formatter $formatter, Event $event, $eventName)
45     {
46         foreach ($this->listeners as $listener) {
47             $listener->listenEvent($formatter, $event, $eventName);
48         }
49     }
50
51     /**
52      * {@inheritdoc}
53      */
54     public function count()
55     {
56         return count($this->listeners);
57     }
58
59     /**
60      * {@inheritdoc}
61      */
62     public function getIterator()
63     {
64         return new ArrayIterator($this->listeners);
65     }
66 }