3 declare(strict_types=1);
57 const PIMP =
'[\\+\\-\\.]';
72 const PCHAR = self::UNRESERVED .
'|' . self::SUBDELIMS .
'|' . self::PCTENCODED .
'|:|@';
73 const BASEURI_PCHAR = self::UNRESERVED .
'|' . self::BASEURI_SUBDELIMS .
'|' . self::PCTENCODED .
'|:|@';
75 const SCHEMA =
'#^' . self::ALPHA .
'(' . self::ALPHA_DIGIT .
'|' . self::PIMP .
')*$#';
76 const DOMAIN_LABEL = self::ALPHA_DIGIT .
'((' . self::UNRESERVED_NO_DOT .
'|' . self::PCTENCODED .
'|' . self::BASEURI_SUBDELIMS .
')*' . self::ALPHA_DIGIT .
')*';
77 const HOST_REG_NAME =
'^' . self::DOMAIN_LABEL .
'(\\.' . self::DOMAIN_LABEL .
')*$';
78 const HOST_IPV4 =
'^(' . self::DIGIT .
'{1,3})(\\.' . self::DIGIT .
'{1,3}){3}$';
79 const HOST =
'#' . self::HOST_IPV4 .
'|' . self::HOST_REG_NAME .
'#';
80 const PORT =
'#^' . self::DIGIT .
'+$#';
81 const PATH =
'#^(?!//)(?!:)(' . self::PCHAR .
'|' . self::PATH_DELIM .
')+$#';
82 const QUERY =
'#^(' . self::PCHAR .
'|' . self::PATH_DELIM .
'|\\?)+$#';
83 const FRAGMENT =
'#^(' . self::PCHAR .
'|' . self::PATH_DELIM .
'|\\?|\\#)+$#';
88 $this->
host = $this->
digestHost(parse_url($uri_string, PHP_URL_HOST));
89 $this->
port = $this->
digestPort(parse_url($uri_string, PHP_URL_PORT));
90 $this->
path = $this->
digestPath(parse_url($uri_string, PHP_URL_PATH));
127 if (
$port === null) {
142 if (
$path === null) {
194 if (preg_match($regexp, (
string) $string) === 1) {
197 throw new \InvalidArgumentException(
'ill-formated component "' . $string .
'" expected "' . $regexp .
'"');
217 $other = clone $this;
229 if (
$port === null) {
230 return $this->
host();
244 $parts = explode(
':', $authority);
245 if (count($parts) > 2) {
246 throw new \InvalidArgumentException(
'ill-formated component ' . $authority);
250 if (array_key_exists(1, $parts)) {
253 $other = clone $this;
254 $other->host =
$host;
255 $other->port =
$port;
276 $other = clone $this;
277 $other->port =
$port;
284 public function host() : string
298 $other = clone $this;
299 $other->host =
$host;
321 $other = clone $this;
322 $other->path =
$path;
343 $other = clone $this;
365 $other = clone $this;
379 if (
$path === null) {
baseURI()
Get a well-formed URI consisting only out of schema, authority and port.
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.
withPath(string $path=null)
Get URI with modified path.
withQuery(string $query=null)
Get URI with modified query.
digestQuery(string $query=null)
Check query formating.
withSchema(string $schema)
Get URI with modified schema.
const SUBDELIMS
valid subdelims according to RFC 3986 Appendix 1: "!" "$" "&" "'" "(" ")" "*" "+" "...
digestHost(string $host)
Check host formating.
__construct(string $uri_string)
The scope of this class is split ilias-conform URI's into components.
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.