Skip to content
This repository was archived by the owner on Sep 6, 2025. It is now read-only.

Commit a94294f

Browse files
committed
Interface segregation here makes more sense
1 parent 327741e commit a94294f

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

src/EventDispatcher/EventDispatcherInterface.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@
88
interface EventDispatcherInterface
99
{
1010
/**
11-
* @param $eventName
11+
* Dispatches an event
12+
* @param string $eventName The name of the event
1213
* @param array ...$arguments
1314
*/
1415
public function dispatch($eventName, ...$arguments);
15-
16-
/**
17-
* @param string $eventName
18-
* @param callable $callable
19-
*/
20-
public function addListener($eventName, callable $callable);
21-
}
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace HelloFresh\Engine\EventDispatcher;
4+
5+
/**
6+
* Base type for an event listener.
7+
*/
8+
interface EventListenerInterface
9+
{
10+
/**
11+
* Adds a listener to an event
12+
* @param string $eventName The event name
13+
* @param callable $callable The callable that will be called when the event happens
14+
*/
15+
public function addListener($eventName, callable $callable);
16+
}

src/EventDispatcher/EventDispatcher.php renamed to src/EventDispatcher/InMemoryDispatcher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
use Collections\MapInterface;
88

99
/**
10-
* Event dispatcher implementation.
10+
* In Memory Event dispatcher implementation.
1111
*/
12-
class EventDispatcher implements EventDispatcherInterface
12+
class InMemoryDispatcher implements EventDispatcherInterface, EventListenerInterface
1313
{
1414
/**
1515
* @var MapInterface

0 commit comments

Comments
 (0)