/** * We want $eventHandler to be called whenever an event of type $eventName * is dispatch to the event stream $stream * * @param EventStream $stream * the stream we want to register the event handler on * @param string $eventName * the event we want to handle * @param callable $eventHandler * the handler we want called * @return void */ public static function on(EventStream $stream, $eventName, $eventHandler) { RequireEventName::check($eventName); RequireCallable::check($eventHandler, E4xx_UnsupportedType::class); if (!isset($stream->{$eventName})) { $stream->{$eventName} = []; } $stream->{$eventName}[] = $eventHandler; }
/** * @covers ::check * @dataProvider provideNonCallables * @expectedException GanbaroDigital\Reflection\Exceptions\E4xx_UnsupportedType */ public function testRejectsNonNullsWhenCalledStatically($item) { // ---------------------------------------------------------------- // setup your test // ---------------------------------------------------------------- // perform the change RequireCallable::check($item); }