src/Url.php
private static function mySplit(string $url, ?string &$schemeString = null, ?string &$authorityString = null, ?string &$pathString = null): void
    {
        $schemeString = null;
        $authorityString = null;
        $pathString = null;

        $parts = explode('://', $url, 2);

        if (count($parts) === 2) {
            // Absolute url.
            $schemeString = $parts[0];
            $parts = explode('/', $parts[1], 2);
            $authorityString = $parts[0];
            $pathString = '/' . (count($parts) === 2 ? $parts[1] : '');

            return;
        }

        if (substr($url, 0, 2) === '//') {
            // Relative url beginning with "//".
            $parts = explode('/', substr($url, 2), 2);
            $authorityString = $parts[0];
            $pathString = '/' . (count($parts) === 2 ? $parts[1] : '');

            return;
        }

        // Relative url as a path.
        $pathString = $url;
    }
private static function mySplit(string $url, ?string &$schemeString = null, ?string &$authorityString = null, ?string &$pathString = null): void
    {
        $schemeString = null;
        $authorityString = null;
        $pathString = null;

        $parts = explode('://', $url, 2);

        if (count($parts) === 2) {
            // Absolute url.
            $schemeString = $parts[0];
            $parts = explode('/', $parts[1], 2);
            $authorityString = $parts[0];
            $pathString = '/' . (count($parts) === 2 ? $parts[1] : '');

            return;
        }

        if (substr($url, 0, 2) === '//') {
            // Relative url beginning with "//".
            $parts = explode('/', substr($url, 2), 2);
            $authorityString = $parts[0];
            $pathString = '/' . (count($parts) === 2 ? $parts[1] : '');

            return;
        }

        // Relative url as a path.
        $pathString = $url;
    }
private static function mySplit ( string $ url , ? string & $ schemeString = null , ? string & $ authorityString = null , ? string & $ pathString = null ) : void { $ schemeString = null ; $ authorityString = null ; $ pathString = null ; $ parts = explode ( '://' , $ url , 2 ) ; if ( count ( $ parts ) === 2 ) { // Absolute url. $ schemeString = $ parts [ 0 ] ; $ parts = explode ( '/' , $ parts [ 1 ] , 2 ) ; $ authorityString = $ parts [ 0 ] ; $ pathString = '/' . ( count ( $ parts ) === 2 ? $ parts [ 1 ] : '' ) ; return ; } if ( substr ( $ url , 0 , 2 ) === '//' ) { // Relative url beginning with "//". $ parts = explode ( '/' , substr ( $ url , 2 ) , 2 ) ; $ authorityString = $ parts [ 0 ] ; $ pathString = '/' . ( count ( $ parts ) === 2 ? $ parts [ 1 ] : '' ) ; return ; } // Relative url as a path. $ pathString = $ url ; }
Splits a url in its main components.

@param string      $url             The url.
@param string|null $schemeString    The scheme or null if scheme is not present.
@param string|null $authorityString The authority part or null if authority part is not present.
@param string|null $pathString      The path or null if path is not present.
Splits a url in its main components .