Code Duplication    Length = 10-11 lines in 2 locations

src/Dispatcher.php 1 location

@@ 80-90 (lines=11) @@
77
        }
78
    }
79
80
    protected function getListeners(object $event): iterable
81
    {
82
        $queue = new PriorityQueue();
83
        foreach ($this->providers as $provider) {
84
            $q = $provider->getListenersForEvent($event);
85
            if (count($q)) {
86
                $queue = $queue->combine($q);
87
            }
88
        }
89
        return $queue;
90
    }
91
}
92

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 PriorityQueue();
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