Router

Build Status Code Coverage Scrutinizer Code Quality SensioLabsInsight

The Router Component.

Example

<?php

use miBadger/Router/Router;

/**
 * Create a new router.
 */
$router = new Router();

/**
 * Create a method route.
 */
$router->set('GET', '/method/', 'method');

/**
 * Create a class method route.
 */
$router->set('GET', '/class/', ['Class', 'method']);

/**
 * Create a closure route.
 */
$router->set('GET', '/closure/', function() {
    return 'result';
});

/**
 * Create a wildcard route.
 */
$router->set('GET', '/test/{wildcard}/', function($wildcard) {
    return $wildcard;
});

/**
 * Add multiple methods for a route.
 */
$router->set(['GET', 'POST', 'TEST'], '/route/', function() {
    return 'result';
});

/**
 * Resolve
 */
$router->resolve();