• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

68publishers / event-dispatcher-extra / 15322966619

29 May 2025 11:35AM UTC coverage: 83.824%. First build
15322966619

Pull #1

github

web-flow
Merge f84369011 into 858a38b40
Pull Request #1: PHP 8.4 support + checks

57 of 68 new or added lines in 4 files covered. (83.82%)

57 of 68 relevant lines covered (83.82%)

0.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.33
/src/EventDispatcherAwareTrait.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace SixtyEightPublishers\EventDispatcherExtra;
6

7
use RuntimeException;
8
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
9

10
trait EventDispatcherAwareTrait
11
{
12
    protected ?EventDispatcherInterface $eventDispatcher = null;
13

14
    public function setEventDispatcher(EventDispatcherInterface $eventDispatcher): void
15
    {
16
        $this->eventDispatcher = $eventDispatcher;
1✔
17
    }
1✔
18

19
    public function getEventDispatcher(): EventDispatcherInterface
20
    {
21
        if (null === $this->eventDispatcher) {
1✔
22
            throw new RuntimeException(sprintf(
1✔
23
                'Event dispatcher is not set, please use method %s::setEventDispatcher().',
1✔
24
                static::class,
1✔
25
            ));
26
        }
27

28
        return $this->eventDispatcher;
1✔
29
    }
30

31
    public function addEventListener(string $eventName, callable $listener, int $priority = 0): void
32
    {
NEW
33
        $this->getEventDispatcher()->addListener(
×
NEW
34
            eventName: $eventName,
×
35
            listener: $listener,
36
            priority: $priority,
37
        );
NEW
38
    }
×
39

40
    protected function dispatchEvent(object $event, ?string $eventName = null): object
41
    {
NEW
42
        return $this->getEventDispatcher()->dispatch(
×
NEW
43
            event: $event,
×
44
            eventName: $eventName,
45
        );
46
    }
47
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc