4 * This file is part of the Behat.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Testwork\Output\Node\EventListener;
14 use Behat\Testwork\Output\Formatter;
16 use IteratorAggregate;
17 use Symfony\Component\EventDispatcher\Event;
20 * Used to compose formatter event listeners.
22 * @author Konstantin Kudryashov <ever.zet@gmail.com>
24 class ChainEventListener implements EventListener, Countable, IteratorAggregate
27 * @var EventListener[]
32 * Initializes collection.
34 * @param EventListener[] $listeners
36 public function __construct(array $listeners)
38 $this->listeners = $listeners;
44 public function listenEvent(Formatter $formatter, Event $event, $eventName)
46 foreach ($this->listeners as $listener) {
47 $listener->listenEvent($formatter, $event, $eventName);
54 public function count()
56 return count($this->listeners);
62 public function getIterator()
64 return new ArrayIterator($this->listeners);