3 declare(strict_types=1);
25 private const ALPHA =
'[A-Za-z]';
28 private const HEXDIG =
'[0-9A-Fa-f]';
29 private const PCTENCODED =
'%' . self::HEXDIG . self::HEXDIG;
33 private const PIMP =
'[\\+\\-\\.]';
39 private const SUBDELIMS =
'[\\$,;=!&\'\\(\\)\\*\\+]';
45 private const UNRESERVED = self::ALPHA_DIGIT .
'|[\\-\\._~]';
48 private const PCHAR = self::UNRESERVED .
'|' . self::SUBDELIMS .
'|' . self::PCTENCODED .
'|:|@';
49 private const BASEURI_PCHAR = self::UNRESERVED .
'|' . self::BASEURI_SUBDELIMS .
'|' . self::PCTENCODED .
'|:|@';
51 private const SCHEMA =
'#^' . self::ALPHA .
'(' . self::ALPHA_DIGIT .
'|' . self::PIMP .
')*$#';
52 private const DOMAIN_LABEL = self::ALPHA_DIGIT .
'((' . self::UNRESERVED_NO_DOT .
'|' . self::PCTENCODED .
'|' . self::BASEURI_SUBDELIMS .
')*' . self::ALPHA_DIGIT .
')*';
53 private const HOST_REG_NAME =
'^' . self::DOMAIN_LABEL .
'(\\.' . self::DOMAIN_LABEL .
')*$';
55 private const HOST_IPV4 =
'^' . self::HOST_IPV4_EMBEDDED .
'$';
59 private const IPV6_LEFT_SHORT =
'(' . self::HEXDIG .
'{1,4}|' . self::HEXDIG .
'{1,4}(:' . self::HEXDIG .
'{1,4})*)?';
63 private const HOST_IPV6_LONG =
'^\\[' . self::IPV6_COUNT_COLONS .
'{7}' . self::HEXDIG .
'{1,4}\\]$';
65 private const HOST_IPV6_SHORT =
'^\\[(?=' . self::IPV6_COLONS_BETWEEN .
'{2,7}\\]$)' .
66 self::IPV6_LEFT_SHORT .
'::' .
68 '(' . self::HEXDIG .
'{1,4}|(' . self::HEXDIG .
'{1,4}:)*' . self::HEXDIG .
'{1,4})?\\]$';
71 private const HOST_IPV6_EMBEDDED_IPV4_LONG =
'^\\[' . self::IPV6_COUNT_COLONS .
'{5}' . self::HEXDIG .
'{1,4}:' . self::HOST_IPV4_EMBEDDED .
'\\]$';
74 self::IPV6_LEFT_SHORT .
'::' .
77 '(' . self::HEXDIG .
'{1,4}|(' . self::HEXDIG .
'{1,4}:)*' . self::HEXDIG .
'{0,4})?' . self::HOST_IPV4_EMBEDDED .
'\\]$';
81 private const HOST_IPV6 = self::HOST_IPV6_LONG .
'|' . self::HOST_IPV6_SHORT .
'|' . self::HOST_IPV6_EMBEDDED_IPV4;
82 private const HOST =
'#' . self::HOST_IPV4 .
'|' . self::HOST_REG_NAME .
'|' . self::HOST_IPV6 .
'#';
83 private const PORT =
'#^' . self::DIGIT .
'+$#';
84 private const PATH =
'#^(?!//)(?!:)(' . self::PCHAR .
'|' . self::PATH_DELIM .
')+$#';
85 private const QUERY =
'#^(' . self::PCHAR .
'|' . self::PATH_DELIM .
'|\\?)+$#';
86 private const FRAGMENT =
'#^(' . self::PCHAR .
'|' . self::PATH_DELIM .
'|\\?|\\#)+$#';
97 $this->schema = $this->
digestSchema(parse_url($uri_string, PHP_URL_SCHEME));
98 $this->host = $this->
digestHost(parse_url($uri_string, PHP_URL_HOST));
99 $this->port = $this->
digestPort(parse_url($uri_string, PHP_URL_PORT));
100 $this->path = $this->
digestPath(parse_url($uri_string, PHP_URL_PATH));
101 $this->query = $this->
digestQuery(parse_url($uri_string, PHP_URL_QUERY));
102 $this->fragment = $this->
digestFragment(parse_url($uri_string, PHP_URL_FRAGMENT));
126 return $port ?? null;
134 if ($path === null) {
149 if ($query === null) {
160 if ($fragment === null) {
173 if (preg_match($regexp, $string) === 1) {
176 throw new \InvalidArgumentException(
'ill-formated component "' . $string .
'" expected "' . $regexp .
'"');
190 $other = clone $this;
198 if ($port === null) {
209 $parts = explode(
':', $authority);
211 throw new \InvalidArgumentException(
'ill-formated component ' . $authority);
215 if (array_key_exists(1,
$parts)) {
218 $other = clone $this;
219 $other->host =
$host;
220 $other->port =
$port;
235 $other = clone $this;
236 $other->port =
$port;
251 $other = clone $this;
252 $other->host =
$host;
267 $other = clone $this;
268 $other->path =
$path;
283 $other = clone $this;
299 $other = clone $this;
311 if ($path === null) {
338 if (!is_null($query)) {
361 http_build_query($parameters)
withFragment(string $fragment=null)
Get URI with modified fragment.
withHost(string $host)
Get URI with modified host.
const PIMP
point|minus|plus to be used in schema.
const ALPHA
Relevant character-groups as defined in RFC 3986 Appendix 1.
withParameters(array $parameters)
Get URI with modified parameters.
withPath(string $path=null)
Get URI with modified path.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
withQuery(string $query=null)
Get URI with modified query.
digestQuery(string $query=null)
Check query formating.
const HOST_IPV6_EMBEDDED_IPV4_LONG
withSchema(string $schema)
Get URI with modified schema.
const SUBDELIMS
valid subdelims according to RFC 3986 Appendix 1: "!" "$" "&" "'" "(" ")" "*" "+" "...
const HOST_IPV6_EMBEDDED_IPV4_SHORT
getParameters()
Get all parameters as associative array.
getParameter(string $param)
Get the value of the given parameter (or null)
digestHost(string $host)
Check host formating.
__construct(string $uri_string)
const IPV6_COLONS_BETWEEN
The scope of this class is split ilias-conform URI's into components.
const HOST_IPV6_EMBEDDED_IPV4
getBaseURI()
Get a well-formed URI consisting only of schema, authority and port.
checkCorrectFormatOrThrow(string $regexp, string $string)
Check wether a string fits a regexp.
if(strtoupper($DIC->http() ->request() ->getMethod()) !=="GET") $params
digestPath(string $path=null)
Check path formating.
digestPort(int $port=null)
Check port formating.
digestSchema(string $schema)
Check schema formating.
withPort(int $port=null)
Get URI with modified port.
digestFragment(string $fragment=null)
Check fragment formating.
const BASEURI_SUBDELIMS
subdelims without jsf**k characters +!() and =
withAuthority(string $authority)
Get URI with modified authority.
withParameter(string $key, $value)
Get URI with modified parameters.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...