19declare(strict_types=1);
41 private const ALPHA =
'[A-Za-z]';
44 private const HEXDIG =
'[0-9A-Fa-f]';
49 private const PIMP =
'[\\+\\-\\.]';
55 private const SUBDELIMS =
'[\\$,;=!&\'\\(\\)\\*\\+]';
61 private const UNRESERVED = self::ALPHA_DIGIT .
'|[\\-\\._~]';
66 private const SCHEMA =
'#^' . self::ALPHA .
'(' . self::ALPHA_DIGIT .
'|' . self::PIMP .
')*$#';
67 private const DOMAIN_LABEL = self::ALPHA_DIGIT .
'((' . self::UNRESERVED_NO_DOT .
'|' . self::PCTENCODED .
'|' . self::BASEURI_SUBDELIMS .
')*' . self::ALPHA_DIGIT .
')*';
68 private const HOST_REG_NAME =
'^' . self::DOMAIN_LABEL .
'(\\.' . self::DOMAIN_LABEL .
')*$';
70 private const HOST_IPV4 =
'^' . self::HOST_IPV4_EMBEDDED .
'$';
74 private const IPV6_LEFT_SHORT =
'(' . self::HEXDIG .
'{1,4}|' . self::HEXDIG .
'{1,4}(:' . self::HEXDIG .
'{1,4})*)?';
78 private const HOST_IPV6_LONG =
'^\\[' . self::IPV6_COUNT_COLONS .
'{7}' . self::HEXDIG .
'{1,4}\\]$';
80 private const HOST_IPV6_SHORT =
'^\\[(?=' . self::IPV6_COLONS_BETWEEN .
'{2,7}\\]$)' .
81 self::IPV6_LEFT_SHORT .
'::' .
83 '(' . self::HEXDIG .
'{1,4}|(' . self::HEXDIG .
'{1,4}:)*' . self::HEXDIG .
'{1,4})?\\]$';
86 private const HOST_IPV6_EMBEDDED_IPV4_LONG =
'^\\[' . self::IPV6_COUNT_COLONS .
'{5}' . self::HEXDIG .
'{1,4}:' . self::HOST_IPV4_EMBEDDED .
'\\]$';
89 self::IPV6_LEFT_SHORT .
'::' .
92 '(' . self::HEXDIG .
'{1,4}|(' . self::HEXDIG .
'{1,4}:)*' . self::HEXDIG .
'{0,4})?' . self::HOST_IPV4_EMBEDDED .
'\\]$';
97 private const HOST =
'#' . self::HOST_IPV4 .
'|' . self::HOST_REG_NAME .
'|' . self::HOST_IPV6 .
'#';
98 private const PORT =
'#^' . self::DIGIT .
'+$#';
99 private const PATH =
'#^(?!//)(?!:)(' . self::PCHAR .
'|' . self::PATH_DELIM .
')+$#';
100 private const QUERY =
'#^(' . self::PCHAR .
'|' . self::PATH_DELIM .
'|\\?)+$#';
101 private const FRAGMENT =
'#^(' . self::PCHAR .
'|' . self::PATH_DELIM .
'|\\?|\\#)+$#';
112 $this->schema = $this->
digestSchema(parse_url($uri_string, PHP_URL_SCHEME));
113 $this->host = $this->
digestHost(parse_url($uri_string, PHP_URL_HOST));
114 $this->port = $this->
digestPort(parse_url($uri_string, PHP_URL_PORT));
115 $this->path = $this->
digestPath(parse_url($uri_string, PHP_URL_PATH));
116 $this->query = $this->
digestQuery(parse_url($uri_string, PHP_URL_QUERY));
117 $this->fragment = $this->
digestFragment(parse_url($uri_string, PHP_URL_FRAGMENT));
141 return $port ??
null;
149 if (
$path ===
null) {
167 $qparts = explode(
'&',
$query);
168 foreach ($qparts as
$q) {
192 if (preg_match($regexp, $string) === 1) {
195 throw new \InvalidArgumentException(
'ill-formated component "' . $string .
'" expected "' . $regexp .
'"');
209 $other = clone $this;
217 if ($port ===
null) {
228 $parts = explode(
':', $authority);
230 throw new \InvalidArgumentException(
'ill-formated component ' . $authority);
234 if (array_key_exists(1,
$parts)) {
237 $other = clone $this;
238 $other->host =
$host;
239 $other->port =
$port;
254 $other = clone $this;
255 $other->port =
$port;
270 $other = clone $this;
271 $other->host =
$host;
286 $other = clone $this;
287 $other->path =
$path;
302 $other = clone $this;
318 $other = clone $this;
330 if ($path ===
null) {
380 http_build_query($parameters)
The scope of this class is split ilias-conform URI's into components.
digestPath(?string $path=null)
Check path formating.
withParameters(array $parameters)
Get URI with modified parameters.
withFragment(?string $fragment=null)
Get URI with modified fragment.
__construct(string $uri_string)
getParameter(string $param)
Get the value of the given parameter (or null)
const IPV6_COLONS_BETWEEN
digestPort(?int $port=null)
Check port formating.
withPath(?string $path=null)
Get URI with modified path.
withSchema(string $schema)
Get URI with modified schema.
const HOST_IPV6_EMBEDDED_IPV4
const HOST_IPV6_EMBEDDED_IPV4_LONG
const BASEURI_SUBDELIMS
subdelims without jsf**k characters +!() and =
digestHost(string $host)
Check host formating.
digestSchema(string $schema)
Check schema formating.
const ALPHA
Relevant character-groups as defined in RFC 3986 Appendix 1.
checkCorrectFormatOrThrow(string $regexp, string $string)
Check wether a string fits a regexp.
digestFragment(?string $fragment=null)
Check fragment formating.
const PIMP
point|minus|plus to be used in schema.
withParameter(string $key, $value)
Get URI with modified parameters.
const HOST_IPV6_EMBEDDED_IPV4_SHORT
digestQuery(?string $query=null)
Check query formating.
getBaseURI()
Get a well-formed URI consisting only of schema, authority and port.
getParameters()
Get all parameters as associative array.
withPort(?int $port=null)
Get URI with modified port.
withHost(string $host)
Get URI with modified host.
withQuery(?string $query=null)
Get URI with modified query.
withAuthority(string $authority)
Get URI with modified authority.
const SUBDELIMS
valid subdelims according to RFC 3986 Appendix 1: "!" "$" "&" "'" "(" ")" "*" "+" ",...
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts