19 declare(strict_types=1);
41 private const ALPHA =
'[A-Za-z]';
44 private const HEXDIG =
'[0-9A-Fa-f]';
45 private const PCTENCODED =
'%' . self::HEXDIG . self::HEXDIG;
49 private const PIMP =
'[\\+\\-\\.]';
55 private const SUBDELIMS =
'[\\$,;=!&\'\\(\\)\\*\\+]';
61 private const UNRESERVED = self::ALPHA_DIGIT .
'|[\\-\\._~]';
64 private const PCHAR = self::UNRESERVED .
'|' . self::SUBDELIMS .
'|' . self::PCTENCODED .
'|:|@';
65 private const BASEURI_PCHAR = self::UNRESERVED .
'|' . self::BASEURI_SUBDELIMS .
'|' . self::PCTENCODED .
'|:|@';
67 private const SCHEMA =
'#^' . self::ALPHA .
'(' . self::ALPHA_DIGIT .
'|' . self::PIMP .
')*$#';
68 private const DOMAIN_LABEL = self::ALPHA_DIGIT .
'((' . self::UNRESERVED_NO_DOT .
'|' . self::PCTENCODED .
'|' . self::BASEURI_SUBDELIMS .
')*' . self::ALPHA_DIGIT .
')*';
69 private const HOST_REG_NAME =
'^' . self::DOMAIN_LABEL .
'(\\.' . self::DOMAIN_LABEL .
')*$';
71 private const HOST_IPV4 =
'^' . self::HOST_IPV4_EMBEDDED .
'$';
75 private const IPV6_LEFT_SHORT =
'(' . self::HEXDIG .
'{1,4}|' . self::HEXDIG .
'{1,4}(:' . self::HEXDIG .
'{1,4})*)?';
79 private const HOST_IPV6_LONG =
'^\\[' . self::IPV6_COUNT_COLONS .
'{7}' . self::HEXDIG .
'{1,4}\\]$';
81 private const HOST_IPV6_SHORT =
'^\\[(?=' . self::IPV6_COLONS_BETWEEN .
'{2,7}\\]$)' .
82 self::IPV6_LEFT_SHORT .
'::' .
84 '(' . self::HEXDIG .
'{1,4}|(' . self::HEXDIG .
'{1,4}:)*' . self::HEXDIG .
'{1,4})?\\]$';
87 private const HOST_IPV6_EMBEDDED_IPV4_LONG =
'^\\[' . self::IPV6_COUNT_COLONS.
'{5}' . self::HEXDIG .
'{1,4}:' . self::HOST_IPV4_EMBEDDED .
'\\]$';
90 self::IPV6_LEFT_SHORT .
'::' .
93 '(' . self::HEXDIG .
'{1,4}|(' . self::HEXDIG .
'{1,4}:)*' . self::HEXDIG .
'{0,4})?' . self::HOST_IPV4_EMBEDDED .
'\\]$';
97 private const HOST_IPV6 = self::HOST_IPV6_LONG .
'|' . self::HOST_IPV6_SHORT .
'|' . self::HOST_IPV6_EMBEDDED_IPV4;
98 private const HOST =
'#' . self::HOST_IPV4 .
'|' . self::HOST_REG_NAME .
'|' . self::HOST_IPV6 .
'#';
99 private const PORT =
'#^' . self::DIGIT .
'+$#';
100 private const PATH =
'#^(?!//)(?!:)(' . self::PCHAR .
'|' . self::PATH_DELIM .
')+$#';
101 private const QUERY =
'#^(' . self::PCHAR .
'|' . self::PATH_DELIM .
'|\\?)+$#';
102 private const FRAGMENT =
'#^(' . self::PCHAR .
'|' . self::PATH_DELIM .
'|\\?|\\#)+$#';
113 $this->schema = $this->
digestSchema(parse_url($uri_string, PHP_URL_SCHEME));
114 $this->host = $this->
digestHost(parse_url($uri_string, PHP_URL_HOST));
115 $this->port = $this->
digestPort(parse_url($uri_string, PHP_URL_PORT));
116 $this->path = $this->
digestPath(parse_url($uri_string, PHP_URL_PATH));
117 $this->query = $this->
digestQuery(parse_url($uri_string, PHP_URL_QUERY));
118 $this->fragment = $this->
digestFragment(parse_url($uri_string, PHP_URL_FRAGMENT));
142 return $port ?? null;
150 if ($path === null) {
165 if ($query === null) {
176 if ($fragment === null) {
189 if (preg_match($regexp, $string) === 1) {
192 throw new \InvalidArgumentException(
'ill-formated component "' . $string .
'" expected "' . $regexp .
'"');
206 $other = clone $this;
214 if ($port === null) {
225 $parts = explode(
':', $authority);
227 throw new \InvalidArgumentException(
'ill-formated component ' . $authority);
231 if (array_key_exists(1,
$parts)) {
234 $other = clone $this;
235 $other->host =
$host;
236 $other->port =
$port;
251 $other = clone $this;
252 $other->port =
$port;
267 $other = clone $this;
268 $other->host =
$host;
283 $other = clone $this;
284 $other->path =
$path;
299 $other = clone $this;
315 $other = clone $this;
327 if ($path === null) {
354 if (!is_null($query)) {
377 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
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
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.
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.