src/Lego/Foundation/Event.php
public function register($event, $listener, \Closure $callback)
    {
        if (!isset($this->events[$event])) {
            $this->events[$event] = [];
        }

        if ($listener) {
            $this->events[$event][$listener] = $callback;
        } else {
            $this->events[$event][] = $callback;
            $keys = array_keys($this->events[$event]);
            $listener = array_pop($keys);
        }

        return $listener;
    }
public function register($event, $listener, \Closure $callback)
    {
        if (!isset($this->events[$event])) {
            $this->events[$event] = [];
        }

        if ($listener) {
            $this->events[$event][$listener] = $callback;
        } else {
            $this->events[$event][] = $callback;
            $keys = array_keys($this->events[$event]);
            $listener = array_pop($keys);
        }

        return $listener;
    }
public function register ( $ event , $ listener , \ Closure $ callback ) { if ( ! isset ( $ this -> events [ $ event ] ) ) { $ this -> events [ $ event ] = [ ] ; } if ( $ listener ) { $ this -> events [ $ event ] [ $ listener ] = $ callback ; } else { $ this -> events [ $ event ] [ ] = $ callback ; $ keys = array_keys ( $ this -> events [ $ event ] ) ; $ listener = array_pop ( $ keys ) ; } return $ listener ; }
Register event.

@param string   $event    event name
@param string   $listener listener name
@param \Closure $callback call when fire

@return string|int
Register event .