src/Event/EventManager.php
public function bind(string $event, callable $callback) {
        // We can't bind to something that isn't callable
        if (!is_callable($callback)) {
            return false;
        }

        if (!isset($this->bindings[$event]) || !is_array($this->bindings[$event])) {
            $this->bindings[$event] = [];
        }

        // Check if this event is already registered
        $signature = $this->hash($callback);
        if (array_key_exists($signature, $this->bindings[$event])) {
            return $signature;
        }

        $this->bindings[$event][$signature] = $callback;
        return $signature;
    }
public function bind(string $event, callable $callback) {
        // We can't bind to something that isn't callable
        if (!is_callable($callback)) {
            return false;
        }

        if (!isset($this->bindings[$event]) || !is_array($this->bindings[$event])) {
            $this->bindings[$event] = [];
        }

        // Check if this event is already registered
        $signature = $this->hash($callback);
        if (array_key_exists($signature, $this->bindings[$event])) {
            return $signature;
        }

        $this->bindings[$event][$signature] = $callback;
        return $signature;
    }
public function bind ( string $ event , callable $ callback ) { // We can't bind to something that isn't callable if ( ! is_callable ( $ callback ) ) { return false ; } if ( ! isset ( $ this -> bindings [ $ event ] ) || ! is_array ( $ this -> bindings [ $ event ] ) ) { $ this -> bindings [ $ event ] = [ ] ; } // Check if this event is already registered $ signature = $ this -> hash ( $ callback ) ; if ( array_key_exists ( $ signature , $ this -> bindings [ $ event ] ) ) { return $ signature ; } $ this -> bindings [ $ event ] [ $ signature ] = $ callback ; return $ signature ; }
Register an event binding

@param string $event
@param callable $callback
@return string|boolean:false
Register an event binding