<commit_before><?php

    class App {
     
        protected static $manifest = array();
        protected static $settings = array();
        
        public function __construct() {
            self::_manifest();
        }
        
        
        /**
         * Get URL from an action
        **/
        public static function url($action, $data = array()) {
            foreach(self::$manifest as $key => $request) {
                
                if($request['name'] == $action):
                    $uri = $request['uri'];
                    foreach($data as $index => $value) {
                        $uri = str_replace(":$index", $value, $uri);
                    }
                    break;
                endif;
            }
            
            return $uri ? path($uri) : false;
        }
        
        
        /**
         * Load manifest for App usage
        **/
        private static function _manifest() {
            $tmp = root(PATH_TMP . '/manifest.json');
            $source = root(PATH_VAR.'/manifest.xml');
            
            if(file_exists($tmp) && (!file_exists($source) || filemtime($source) < filemtime($tmp))):
                self::$manifest = json_decode(file_get_contents($tmp), true);
            
            elseif(file_exists($source)):                
                $dom = new DOMDocument();
                $dom->load($source);
                $manifest = $dom->getElementsByTagName('manifest')->item(0);
                $requests = $manifest->getElementsByTagName('request');
                
                // Analyse request
                foreach($requests as $case) {
                    $parameters = array();
                    $uri = $case->getAttribute('uri');
                    $uri_regexp = $uri;
                    $action = $case->getAttribute('action');
                    $route = ($case->hasAttribute('name') ? $case->getAttribute('name') : $action);
                    if($case->hasAttribute('domain'))
                        $domain = str_replace('~', str_replace('www.', '', SYSTEM_DOMAIN), $case->getAttribute('domain'));
                    else
                        $domain = SYSTEM_DOMAIN;
                    
                    if($case->hasAttribute('methods') && $case->getAttribute('methods') != '' && strtoupper($case->getAttribute('methods')) != 'ANY')
                        $methods = explode('|', strtoupper($case->getAttribute('methods')));
                    else
                        $methods = array('GET', 'POST', 'HEAD', 'PUT');
                                           
                    foreach($case->getElementsByTagName('param') as $param) {
                        $name = $param->getAttribute('name');<commit_msg>Manifest : use spaces to define multiple methods parameter's<commit_after><?php

    class App {
     
        protected static $manifest = array();
        protected static $settings = array();
        
        public function __construct() {
            self::_manifest();
        }
        
        
        /**
         * Get URL from an action
        **/
        public static function url($action, $data = array()) {
            foreach(self::$manifest as $key => $request) {
                
                if($request['name'] == $action):
                    $uri = $request['uri'];
                    foreach($data as $index => $value) {
                        $uri = str_replace(":$index", $value, $uri);
                    }
                    break;
                endif;
            }
            
            return $uri ? path($uri) : false;
        }
        
        
        /**
         * Load manifest for App usage
        **/
        private static function _manifest() {
            $tmp = root(PATH_TMP . '/manifest.json');
            $source = root(PATH_VAR.'/manifest.xml');
            
            if(file_exists($tmp) && (!file_exists($source) || filemtime($source) < filemtime($tmp))):
                self::$manifest = json_decode(file_get_contents($tmp), true);
            
            elseif(file_exists($source)):                
                $dom = new DOMDocument();
                $dom->load($source);
                $manifest = $dom->getElementsByTagName('manifest')->item(0);
                $requests = $manifest->getElementsByTagName('request');
                
                // Analyse request
                foreach($requests as $case) {
                    $parameters = array();
                    $uri = $case->getAttribute('uri');
                    $uri_regexp = $uri;
                    $action = $case->getAttribute('action');
                    $route = ($case->hasAttribute('name') ? $case->getAttribute('name') : $action);
                    if($case->hasAttribute('domain'))
                        $domain = str_replace('~', str_replace('www.', '', SYSTEM_DOMAIN), $case->getAttribute('domain'));
                    else
                        $domain = SYSTEM_DOMAIN;
                    
                    if($case->hasAttribute('methods') && $case->getAttribute('methods') != '' && strtoupper($case->getAttribute('methods')) != 'ANY')
                        $methods = explode(' ', strtoupper($case->getAttribute('methods')));
                    else
                        $methods = array('GET', 'POST', 'HEAD', 'PUT');
                                           
                    foreach($case->getElementsByTagName('param') as $param) {
                        $name = $param->getAttribute('name');
{'fraction_non_alphanumeric': 0.14352771258349883, 'fraction_numerical': 0.0003610760064993681, 'mean_word_length': 1.3238255033557047, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3770207', 'n_tokens_mistral': 1350, 'n_tokens_neox': 1283, 'n_words': 250}