Code Duplication    Length = 14-16 lines in 2 locations

src/Events/EmitsEvents.php 2 locations

@@ 20-33 (lines=14) @@
17
     * @throws \InvalidArgumentException
18
     * @return bool true if emitted, false otherwise
19
     */
20
    private function emitEvent($event)
21
    {
22
        if (is_null($this->eventEmitter)) {
23
            return false;
24
        }
25
26
        if (!is_string($event) && !$event instanceof EventInterface) {
27
            throw new \InvalidArgumentException('Event must be either be of type "string" or instance of League\Event\EventInterface');
28
        }
29
30
        $this->eventEmitter->emit($event);
31
32
        return true;
33
    }
34
35
    /**
36
     * @param EventInterface[]|string[] $events
@@ 40-55 (lines=16) @@
37
     * @throws \InvalidArgumentException
38
     * @return bool true if all emitted, false otherwise
39
     */
40
    private function emitBatchOfEvents(array $events)
41
    {
42
        if (is_null($this->eventEmitter)) {
43
            return false;
44
        }
45
46
        foreach ($events as $e) {
47
            if (!is_string($e) && !$e instanceof EventInterface) {
48
                throw new \InvalidArgumentException('Event must be either be of type "string" or instance of League\Event\EventInterface');
49
            }
50
        }
51
52
        $this->emitBatchOfEvents($events);
53
54
        return true;
55
    }
56
57
    /**
58
     * @return Emitter