UriSequence.php
function mask(iUriSequence $pathUri, $toggle = true)
    {
        # the absolute path when another is not is always masked on
        #- /foo <=> bar ---> /foo
        if (
            ## one is absolute and another is not
            ($this->isAbsolute() || $pathUri->isAbsolute())
            && !($this->isAbsolute() && $pathUri->isAbsolute())
        ) {
            $uri = clone $this;

            if ($pathUri->isAbsolute())
                ### return absolutes one
                $uri->setPath($pathUri->getPath());

            return $uri;
        }


        // ..

        $muchLength = $this->getPath();
        $less       = $pathUri->getPath();

        if ( $toggle && (count($less) > count($muchLength)) ) {
            $muchLength = $less;
            $less = $this->getPath();
        }

        $masked = $muchLength;
        foreach($muchLength as $i => $v) {
            if (!array_key_exists($i, $less) || $v != $less[$i])
                break;

            unset($masked[$i]);
        }

        $uri = clone $this;
        $uri->setPath($masked);
        return $uri;
    }
function mask(iUriSequence $pathUri, $toggle = true)
    {
        # the absolute path when another is not is always masked on
        #- /foo <=> bar ---> /foo
        if (
            ## one is absolute and another is not
            ($this->isAbsolute() || $pathUri->isAbsolute())
            && !($this->isAbsolute() && $pathUri->isAbsolute())
        ) {
            $uri = clone $this;

            if ($pathUri->isAbsolute())
                ### return absolutes one
                $uri->setPath($pathUri->getPath());

            return $uri;
        }


        // ..

        $muchLength = $this->getPath();
        $less       = $pathUri->getPath();

        if ( $toggle && (count($less) > count($muchLength)) ) {
            $muchLength = $less;
            $less = $this->getPath();
        }

        $masked = $muchLength;
        foreach($muchLength as $i => $v) {
            if (!array_key_exists($i, $less) || $v != $less[$i])
                break;

            unset($masked[$i]);
        }

        $uri = clone $this;
        $uri->setPath($masked);
        return $uri;
    }
function mask ( iUriSequence $ pathUri , $ toggle = true ) { # the absolute path when another is not is always masked on #- /foo <=> bar ---> /foo if ( ## one is absolute and another is not ( $ this -> isAbsolute ( ) || $ pathUri -> isAbsolute ( ) ) && ! ( $ this -> isAbsolute ( ) && $ pathUri -> isAbsolute ( ) ) ) { $ uri = clone $ this ; if ( $ pathUri -> isAbsolute ( ) ) ### return absolutes one $ uri -> setPath ( $ pathUri -> getPath ( ) ) ; return $ uri ; } // .. $ muchLength = $ this -> getPath ( ) ; $ less = $ pathUri -> getPath ( ) ; if ( $ toggle && ( count ( $ less ) > count ( $ muchLength ) ) ) { $ muchLength = $ less ; $ less = $ this -> getPath ( ) ; } $ masked = $ muchLength ; foreach ( $ muchLength as $ i => $ v ) { if ( ! array_key_exists ( $ i , $ less ) || $ v != $ less [ $ i ] ) break ; unset ( $ masked [ $ i ] ) ; } $ uri = clone $ this ; $ uri -> setPath ( $ masked ) ; return $ uri ; }
Mask Given PathUri with Current Path

toggle:
/var/www/html <=> /var/www/     ===> html
/uri          <=> contact       ===> /uri
/uri          <=> /contact      ===> uri
/uri/path     <=> /contact      ===> uri/path
/uri/         <=> /uri/contact  ===> (empty)
/uri/         <=> /uri/contact/ ===> contact/

toggle false:
/var/www/     <=> /var/www/html ===> ''

@param iUriSequence $pathUri
@param bool           $toggle  with toggle always bigger path
compared to little one

@return iUriSequence
Mask Given PathUri with Current Path