final public static function analysePath(string $routename, string $path, array $parameters):string
    {
        $arraypath = explode("/", $path);
        $arrayElem = array();
        $narray = array();
        foreach ($arraypath as $one) {
            if (preg_match("/{(.*?)}/", $one)) {
                $nstr = str_replace("{", "", $one);
                $nstr = str_replace("}", "", $nstr);
                array_push($arrayElem, $nstr);
            }
        }

        $countchange = 0;
        if (count($parameters) != count($arrayElem)) {
            throw new Server500(new \ArrayObject(array("explain" =>
                "Parameters count does not matches for $routename route",
                "solution" => "Please check your parameters declaration")));
        }



        foreach ($arrayElem as $uno) {
            if (isset($parameters[$uno]) && $parameters[$uno] != "") {
                if (gettype($parameters[$uno]) == "object" || gettype($parameters[$uno]) == "array") {
                    throw new Server500(new \ArrayObject(array("explain" => "Cannot generate route [".
                        $routename."] :  Invalid type [".gettype($parameters[$uno])."] for route parameters",
                        "solution" => "Define a valid parameter type ([object] and [array] is not allowed)")));
                }

                $narray["{".$uno."}"] = $parameters[$uno];
                $countchange++;
            }
        }

        if (count($parameters) != $countchange) {
            throw new Server500(new \ArrayObject(array("explain" => "Parameter(s) missing for $routename route",
                "solution" => "Please check your parameters declaration")));
        }


        for ($i = 0; $i < count($arraypath); $i++) {
            if (isset($narray[$arraypath[$i]])) {
                $arraypath[$i] = $narray[$arraypath[$i]];
            }
        }

        $path = implode("/", $arraypath);

        return ($path);
    }
final public static function analysePath(string $routename, string $path, array $parameters):string
    {
        $arraypath = explode("/", $path);
        $arrayElem = array();
        $narray = array();
        foreach ($arraypath as $one) {
            if (preg_match("/{(.*?)}/", $one)) {
                $nstr = str_replace("{", "", $one);
                $nstr = str_replace("}", "", $nstr);
                array_push($arrayElem, $nstr);
            }
        }

        $countchange = 0;
        if (count($parameters) != count($arrayElem)) {
            throw new Server500(new \ArrayObject(array("explain" =>
                "Parameters count does not matches for $routename route",
                "solution" => "Please check your parameters declaration")));
        }



        foreach ($arrayElem as $uno) {
            if (isset($parameters[$uno]) && $parameters[$uno] != "") {
                if (gettype($parameters[$uno]) == "object" || gettype($parameters[$uno]) == "array") {
                    throw new Server500(new \ArrayObject(array("explain" => "Cannot generate route [".
                        $routename."] :  Invalid type [".gettype($parameters[$uno])."] for route parameters",
                        "solution" => "Define a valid parameter type ([object] and [array] is not allowed)")));
                }

                $narray["{".$uno."}"] = $parameters[$uno];
                $countchange++;
            }
        }

        if (count($parameters) != $countchange) {
            throw new Server500(new \ArrayObject(array("explain" => "Parameter(s) missing for $routename route",
                "solution" => "Please check your parameters declaration")));
        }


        for ($i = 0; $i < count($arraypath); $i++) {
            if (isset($narray[$arraypath[$i]])) {
                $arraypath[$i] = $narray[$arraypath[$i]];
            }
        }

        $path = implode("/", $arraypath);

        return ($path);
    }
final public static function analysePath ( string $ routename , string $ path , array $ parameters ) : string { $ arraypath = explode ( "/" , $ path ) ; $ arrayElem = array ( ) ; $ narray = array ( ) ; foreach ( $ arraypath as $ one ) { if ( preg_match ( "/{(.*?)}/" , $ one ) ) { $ nstr = str_replace ( "{" , "" , $ one ) ; $ nstr = str_replace ( "}" , "" , $ nstr ) ; array_push ( $ arrayElem , $ nstr ) ; } } $ countchange = 0 ; if ( count ( $ parameters ) != count ( $ arrayElem ) ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Parameters count does not matches for $routename route" , "solution" => "Please check your parameters declaration" ) ) ) ; } foreach ( $ arrayElem as $ uno ) { if ( isset ( $ parameters [ $ uno ] ) && $ parameters [ $ uno ] != "" ) { if ( gettype ( $ parameters [ $ uno ] ) == "object" || gettype ( $ parameters [ $ uno ] ) == "array" ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Cannot generate route [" . $ routename . "] :  Invalid type [" . gettype ( $ parameters [ $ uno ] ) . "] for route parameters" , "solution" => "Define a valid parameter type ([object] and [array] is not allowed)" ) ) ) ; } $ narray [ "{" . $ uno . "}" ] = $ parameters [ $ uno ] ; $ countchange ++ ; } } if ( count ( $ parameters ) != $ countchange ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Parameter(s) missing for $routename route" , "solution" => "Please check your parameters declaration" ) ) ) ; } for ( $ i = 0 ; $ i < count ( $ arraypath ) ; $ i ++ ) { if ( isset ( $ narray [ $ arraypath [ $ i ] ] ) ) { $ arraypath [ $ i ] = $ narray [ $ arraypath [ $ i ] ] ; } } $ path = implode ( "/" , $ arraypath ) ; return ( $ path ) ; }
Analyse path to change dynamic parameters with specific parameters array
@param string $routename The route name
@param string $path The route path
@param array $parameters Parameters to change
@return string The new path
@throws Server500 If parameters count does not match or parameter missing
Analyse path to change dynamic parameters with specific parameters array