<commit_before><?php
namespace Roller;
use Iterator;
use Roller\RouteCompiler;
use Exception;

class RouteSet implements Iterator
{
    public $routesMap = array();

    public $before = array();

    public $routes = array();

    public $i = 0;

    public function __call($m,$a) {
        switch( $m ) {
        case 'post':
        case 'head':
        case 'get':
            $path = $a[0];
            $callback = $a[1];
            $options = isset($a[2]) ? $a[2] : array();
            $options[':method'] = $m;
            return $this->add( $path , $callback , $options );
            break;
        }
        throw new Exception("Method $m not found.");
    }



    /**
     * __call magic is always slow than methods 
     */
    public function get($path, $callback, $options = array() )
    {
        $options[':method'] = 'get';
        return $this->add( $path,  $callback , $options );
    }

    public function post($path, $callback, $options = array() )
    {
        $options[':method'] = 'post';
        return $this->add( $path, $callback, $options );
    }



    protected function _buildRoute($path,$callback,$options = array() )
    {
        $route = array(
            'path' => null,
            'args' => null,
        );
        $route['path']        = $path;

        if( is_string($callback) && false !== strpos($callback,':') ) {
            $callback = explode(':',$callback);
        }<commit_msg>doc update<commit_after><?php
namespace Roller;
use Iterator;
use Roller\RouteCompiler;
use Exception;

class RouteSet implements Iterator
{
    public $routesMap = array();

    public $before = array();

    public $routes = array();

    public $i = 0;

    public function __call($m,$a) {
        switch( $m ) {
        case 'post':
        case 'head':
        case 'get':
            $path = $a[0];
            $callback = $a[1];
            $options = isset($a[2]) ? $a[2] : array();
            $options[':method'] = $m;
            return $this->add( $path , $callback , $options );
            break;
        }
        throw new Exception("Method $m not found.");
    }



    /**
     * __call magic is always slow than methods 
     */
    public function get($path, $callback, $options = array() )
    {
        $options[':method'] = 'get';
        return $this->add( $path,  $callback , $options );
    }

    public function post($path, $callback, $options = array() )
    {
        $options[':method'] = 'post';
        return $this->add( $path, $callback, $options );
    }





    /**
     * using pure php to build route
     */
    protected function _buildRoute($path,$callback,$options = array() )
    {
        $route = array(
            'path' => null,
            'args' => null,
        );
        $route['path']        = $path;

        if( is_string($callback) && false !== strpos($callback,':') ) {
            $callback = explode(':',$callback);
        }
{'fraction_non_alphanumeric': 0.16632443531827515, 'fraction_numerical': 0.0034223134839151265, 'mean_word_length': 1.9317953861584753, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1968028', 'n_tokens_mistral': 888, 'n_tokens_neox': 864, 'n_words': 225}