public function match(string $event): array
    {
        $matches = [];

        //do the obvious match
        if (isset($this->observers[$event])) {
            $matches[$event] = array(
                'event' => $event,
                'pattern' => $event,
                'variables' => []
            );
        }

        //deal with regexp
        foreach ($this->regex as $pattern) {
            //if it matches
            if (preg_match_all($pattern, $event, $match)) {
                $variables = [];

                if (is_array($match) && !empty($match)) {
                    //flatten
                    $variables = call_user_func_array('array_merge', $match);
                    array_shift($variables);
                }

                $matches[$pattern] = array(
                    'event' => $event,
                    'pattern' => $pattern,
                    'variables' => $variables
                );
            }
        }

        return array_values($matches);
    }
public function match(string $event): array
    {
        $matches = [];

        //do the obvious match
        if (isset($this->observers[$event])) {
            $matches[$event] = array(
                'event' => $event,
                'pattern' => $event,
                'variables' => []
            );
        }

        //deal with regexp
        foreach ($this->regex as $pattern) {
            //if it matches
            if (preg_match_all($pattern, $event, $match)) {
                $variables = [];

                if (is_array($match) && !empty($match)) {
                    //flatten
                    $variables = call_user_func_array('array_merge', $match);
                    array_shift($variables);
                }

                $matches[$pattern] = array(
                    'event' => $event,
                    'pattern' => $pattern,
                    'variables' => $variables
                );
            }
        }

        return array_values($matches);
    }
public function match ( string $ event ) : array { $ matches = [ ] ; //do the obvious match if ( isset ( $ this -> observers [ $ event ] ) ) { $ matches [ $ event ] = array ( 'event' => $ event , 'pattern' => $ event , 'variables' => [ ] ) ; } //deal with regexp foreach ( $ this -> regex as $ pattern ) { //if it matches if ( preg_match_all ( $ pattern , $ event , $ match ) ) { $ variables = [ ] ; if ( is_array ( $ match ) && ! empty ( $ match ) ) { //flatten $ variables = call_user_func_array ( 'array_merge' , $ match ) ; array_shift ( $ variables ) ; } $ matches [ $ pattern ] = array ( 'event' => $ event , 'pattern' => $ pattern , 'variables' => $ variables ) ; } } return array_values ( $ matches ) ; }
Returns possible event matches

@param *string $event

@return array
Returns possible event matches