Code Duplication    Length = 10-12 lines in 2 locations

src/Dispatcher.php 1 location

@@ 83-94 (lines=12) @@
80
     * @param  object $event
81
     * @return iterable
82
     */
83
    protected function getListeners(object $event): iterable
84
    {
85
        $queue = new UniquePriorityQueue();
86
        foreach ($this->providers as $provider) {
87
            /** @var UniquePriorityQueue $q */
88
            $q = $provider->getListenersForEvent($event);
89
            if (count($q)) {
90
                $queue = $queue->combine($q);
91
            }
92
        }
93
        return $queue;
94
    }
95
}

src/Provider.php 1 location

@@ 41-50 (lines=10) @@
38
     *   An iterable (array, iterator, or generator) of callables.  Each
39
     *   callable MUST be type-compatible with $event.
40
     */
41
    public function getListenersForEvent(object $event): iterable
42
    {
43
        $queue = new UniquePriorityQueue();
44
        foreach ($this->listened as $class => $q) {
45
            if (is_a($event, $class) && count($q)) {
46
                $queue = $queue->combine($q);
47
            }
48
        }
49
        return $queue;
50
    }
51
52
    /**
53
     * Attach a listener (with default priority 50) to the provider