final protected function buildUrl($fragments)
    {
        // Verify url path
        if (!isset($fragments[0])) {
            throw new InvalidFragmentsParameter('Invalid base url structure, http:// path must exists at position [0]', 1);
        }

        // Cleaning up
        $url = $fragments[0];
        unset($fragments[0]);

        // Begin process for make replacements
        if (isset($fragments[1]) && is_array($fragments[1])) {
            $replacements = [];
            $params = $fragments[1];

            // Add { } to each element of the array
            array_walk($params, function (&$item, $key) use (&$replacements) {
                $replacements['{'.$key.'}'] = $item;
            });
        }

        return str_replace(array_keys($replacements), array_values($replacements), $url);
    }
final protected function buildUrl($fragments)
    {
        // Verify url path
        if (!isset($fragments[0])) {
            throw new InvalidFragmentsParameter('Invalid base url structure, http:// path must exists at position [0]', 1);
        }

        // Cleaning up
        $url = $fragments[0];
        unset($fragments[0]);

        // Begin process for make replacements
        if (isset($fragments[1]) && is_array($fragments[1])) {
            $replacements = [];
            $params = $fragments[1];

            // Add { } to each element of the array
            array_walk($params, function (&$item, $key) use (&$replacements) {
                $replacements['{'.$key.'}'] = $item;
            });
        }

        return str_replace(array_keys($replacements), array_values($replacements), $url);
    }
final protected function buildUrl ( $ fragments ) { // Verify url path if ( ! isset ( $ fragments [ 0 ] ) ) { throw new InvalidFragmentsParameter ( 'Invalid base url structure, http:// path must exists at position [0]' , 1 ) ; } // Cleaning up $ url = $ fragments [ 0 ] ; unset ( $ fragments [ 0 ] ) ; // Begin process for make replacements if ( isset ( $ fragments [ 1 ] ) && is_array ( $ fragments [ 1 ] ) ) { $ replacements = [ ] ; $ params = $ fragments [ 1 ] ; // Add { } to each element of the array array_walk ( $ params , function ( & $ item , $ key ) use ( & $ replacements ) { $ replacements [ '{' . $ key . '}' ] = $ item ; } ) ; } return str_replace ( array_keys ( $ replacements ) , array_values ( $ replacements ) , $ url ) ; }
Build url using parameters as fragments.

@param array $fragments Assosiative array of parameters to make the replacement

@return string Final url formed

@throws InvalidFragmentsParameter Invalid parameters as fragments
Build url using parameters as fragments .