src/acdhOeaw/fedora/dissemination/parameter/UriPart.php
public function transform(string $value, string ...$parts): string {
        $value = parse_url($value);

        $toUnset = ['scheme', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment'];
        $toUnset = array_intersect(array_diff($toUnset, $parts), array_keys($value));

        foreach ($toUnset as $i) {
            unset($value[$i]);
        }

        $scheme   = isset($value['scheme']) ? $value['scheme'] . '://' : '';
        $host     = isset($value['host']) ? $value['host'] : '';
        $port     = isset($value['port']) ? ':' . $value['port'] : '';
        $user     = isset($value['user']) ? $value['user'] : '';
        $pass     = isset($value['pass']) ? ':' . $value['pass'] : '';
        $pass     = ($user || $pass) ? "$pass@" : '';
        $path     = isset($value['path']) ? $value['path'] : '';
        $query    = isset($value['query']) ? '?' . $value['query'] : '';
        $fragment = isset($value['fragment']) ? '#' . $value['fragment'] : '';
        return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;
    }
public function transform(string $value, string ...$parts): string {
        $value = parse_url($value);

        $toUnset = ['scheme', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment'];
        $toUnset = array_intersect(array_diff($toUnset, $parts), array_keys($value));

        foreach ($toUnset as $i) {
            unset($value[$i]);
        }

        $scheme   = isset($value['scheme']) ? $value['scheme'] . '://' : '';
        $host     = isset($value['host']) ? $value['host'] : '';
        $port     = isset($value['port']) ? ':' . $value['port'] : '';
        $user     = isset($value['user']) ? $value['user'] : '';
        $pass     = isset($value['pass']) ? ':' . $value['pass'] : '';
        $pass     = ($user || $pass) ? "$pass@" : '';
        $path     = isset($value['path']) ? $value['path'] : '';
        $query    = isset($value['query']) ? '?' . $value['query'] : '';
        $fragment = isset($value['fragment']) ? '#' . $value['fragment'] : '';
        return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;
    }
public function transform ( string $ value , string ... $ parts ) : string { $ value = parse_url ( $ value ) ; $ toUnset = [ 'scheme' , 'host' , 'port' , 'user' , 'pass' , 'path' , 'query' , 'fragment' ] ; $ toUnset = array_intersect ( array_diff ( $ toUnset , $ parts ) , array_keys ( $ value ) ) ; foreach ( $ toUnset as $ i ) { unset ( $ value [ $ i ] ) ; } $ scheme = isset ( $ value [ 'scheme' ] ) ? $ value [ 'scheme' ] . '://' : '' ; $ host = isset ( $ value [ 'host' ] ) ? $ value [ 'host' ] : '' ; $ port = isset ( $ value [ 'port' ] ) ? ':' . $ value [ 'port' ] : '' ; $ user = isset ( $ value [ 'user' ] ) ? $ value [ 'user' ] : '' ; $ pass = isset ( $ value [ 'pass' ] ) ? ':' . $ value [ 'pass' ] : '' ; $ pass = ( $ user || $ pass ) ? "$pass@" : '' ; $ path = isset ( $ value [ 'path' ] ) ? $ value [ 'path' ] : '' ; $ query = isset ( $ value [ 'query' ] ) ? '?' . $ value [ 'query' ] : '' ; $ fragment = isset ( $ value [ 'fragment' ] ) ? '#' . $ value [ 'fragment' ] : '' ; return $ scheme . $ user . $ pass . $ host . $ port . $ path . $ query . $ fragment ; }
Extracts given URL parts.
@param string $value URL to be transformed
@param ... $parts parts to be extracted. One of: scheme (e.g. "https",
"ftp", etc.), host, port, user, pass, path, query, fragment
(part of the URL following #)
@return string
Extracts given URL parts .