src/Utilities/Uri.php
public static function replenishProtocol($url, $protocol = '')
    {
        // Let's trim the url
        if (is_string($url)) {
            $url = trim($url);
        }

        /*
         * Url is not provided?
         * Nothing to do
         */
        if (empty($url)) {
            return '';
        }

        /*
         * It's a valid url?
         * Let's return it
         */
        if (Regex::isValidUrl($url, true)) {
            return $url;
        }

        // Protocol is not provided?
        if (empty($protocol)) {
            $protocol = self::getProtocolName();
        }

        return sprintf('%s://%s', $protocol, $url);
    }
public static function replenishProtocol($url, $protocol = '')
    {
        // Let's trim the url
        if (is_string($url)) {
            $url = trim($url);
        }

        /*
         * Url is not provided?
         * Nothing to do
         */
        if (empty($url)) {
            return '';
        }

        /*
         * It's a valid url?
         * Let's return it
         */
        if (Regex::isValidUrl($url, true)) {
            return $url;
        }

        // Protocol is not provided?
        if (empty($protocol)) {
            $protocol = self::getProtocolName();
        }

        return sprintf('%s://%s', $protocol, $url);
    }
public static function replenishProtocol ( $ url , $ protocol = '' ) { // Let's trim the url if ( is_string ( $ url ) ) { $ url = trim ( $ url ) ; } /*
         * Url is not provided?
         * Nothing to do
         */ if ( empty ( $ url ) ) { return '' ; } /*
         * It's a valid url?
         * Let's return it
         */ if ( Regex :: isValidUrl ( $ url , true ) ) { return $ url ; } // Protocol is not provided? if ( empty ( $ protocol ) ) { $ protocol = self :: getProtocolName ( ) ; } return sprintf ( '%s://%s' , $ protocol , $ url ) ; }
Replenishes protocol in the given url

@param string $url      The url to check and replenish
@param string $protocol (optional) The protocol which is replenished. If is empty, protocol of current request
is used.
@return string
Replenishes protocol in the given url