src/SimpleRoute/Router.php
public function getMethodsByRoute($route)
    {
        // Check if a route was provided
        if (!$route) {
            return [];
        }

        // Loop through our routes
        $methods = [];
        foreach ($this->routes as $method => $routes) {
            foreach ($routes as $availableRoute => $callable) {
                // Check if the available route is the same as the specified route
                if ($availableRoute === $route) {
                    $methods[] = $method;
                    continue 2;
                }

                // Check if the route matches
                $regex = '/^' . str_replace('/', '\/', $availableRoute) . '/Uim';
                if (preg_match($regex, $route, $matches) === 1 && $matches[0] === $route) {
                    $methods[] = $method;
                    continue 2;
                }
            }
        }

        // Return the methods array
        return $methods;
    }
public function getMethodsByRoute($route)
    {
        // Check if a route was provided
        if (!$route) {
            return [];
        }

        // Loop through our routes
        $methods = [];
        foreach ($this->routes as $method => $routes) {
            foreach ($routes as $availableRoute => $callable) {
                // Check if the available route is the same as the specified route
                if ($availableRoute === $route) {
                    $methods[] = $method;
                    continue 2;
                }

                // Check if the route matches
                $regex = '/^' . str_replace('/', '\/', $availableRoute) . '/Uim';
                if (preg_match($regex, $route, $matches) === 1 && $matches[0] === $route) {
                    $methods[] = $method;
                    continue 2;
                }
            }
        }

        // Return the methods array
        return $methods;
    }
public function getMethodsByRoute ( $ route ) { // Check if a route was provided if ( ! $ route ) { return [ ] ; } // Loop through our routes $ methods = [ ] ; foreach ( $ this -> routes as $ method => $ routes ) { foreach ( $ routes as $ availableRoute => $ callable ) { // Check if the available route is the same as the specified route if ( $ availableRoute === $ route ) { $ methods [ ] = $ method ; continue 2 ; } // Check if the route matches $ regex = '/^' . str_replace ( '/' , '\/' , $ availableRoute ) . '/Uim' ; if ( preg_match ( $ regex , $ route , $ matches ) === 1 && $ matches [ 0 ] === $ route ) { $ methods [ ] = $ method ; continue 2 ; } } } // Return the methods array return $ methods ; }
Returns an array of methods defined for a specific route.
Useful for an "OPTIONS" request.

@param string $route The route to get the methods from.

@return array An array with methods.
Returns an array of methods defined for a specific route . Useful for an OPTIONS request .