Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Commit

Permalink
Interface segregation here makes more sense
Browse files Browse the repository at this point in the history
  • Loading branch information
italolelis committed Jun 23, 2016
1 parent 327741e commit a94294f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
11 changes: 3 additions & 8 deletions src/EventDispatcher/EventDispatcherInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@
interface EventDispatcherInterface
{
/**
* @param $eventName
* Dispatches an event
* @param string $eventName The name of the event
* @param array ...$arguments
*/
public function dispatch($eventName, ...$arguments);

/**
* @param string $eventName
* @param callable $callable
*/
public function addListener($eventName, callable $callable);
}
}
16 changes: 16 additions & 0 deletions src/EventDispatcher/EventListenerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace HelloFresh\Engine\EventDispatcher;

/**
* Base type for an event listener.
*/
interface EventListenerInterface
{
/**
* Adds a listener to an event
* @param string $eventName The event name
* @param callable $callable The callable that will be called when the event happens
*/
public function addListener($eventName, callable $callable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Collections\MapInterface;

/**
* Event dispatcher implementation.
* In Memory Event dispatcher implementation.
*/
class EventDispatcher implements EventDispatcherInterface
class InMemoryDispatcher implements EventDispatcherInterface, EventListenerInterface
{
/**
* @var MapInterface
Expand Down

0 comments on commit a94294f

Please sign in to comment.