Skip to content

Commit 06ae7db

Browse files
committed
Adding query prefix modifier methods
1 parent 52acbfc commit 06ae7db

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

Uri.php

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -479,30 +479,23 @@ public static function new(Stringable|string $uri = ''): self
479479
return new self(null, null, null, null, null, '', null, null);
480480
}
481481

482-
$components = UriString::parse($uri);
483-
484-
return new self(
485-
$components['scheme'],
486-
$components['user'],
487-
$components['pass'],
488-
$components['host'],
489-
$components['port'],
490-
$components['path'],
491-
$components['query'],
492-
$components['fragment']
493-
);
482+
return new self(...UriString::parse($uri));
494483
}
495484

496485
/**
497486
* Returns a new instance from a URI and a Base URI.or null on failure.
498487
*
499-
* The returned URI must be absolute.
488+
* The returned URI must be absolute if a base URI is provided
500489
*
501490
* @see https://wiki.php.net/rfc/url_parsing_api
502491
*/
503492
public static function parse(Stringable|string $uri, Stringable|string|null $baseUri = null): ?self
504493
{
505494
try {
495+
if (null === $baseUri) {
496+
return self::new($uri);
497+
}
498+
506499
return self::fromBaseUri($uri, $baseUri);
507500
} catch (Throwable) {
508501
return null;
@@ -514,10 +507,8 @@ public static function parse(Stringable|string $uri, Stringable|string|null $bas
514507
*
515508
* The returned URI must be absolute.
516509
*/
517-
public static function fromBaseUri(
518-
Stringable|string $uri,
519-
Stringable|string|null $baseUri = null
520-
): self {
510+
public static function fromBaseUri(Stringable|string $uri, Stringable|string|null $baseUri = null): self
511+
{
521512
return self::new(UriString::resolve($uri, $baseUri));
522513
}
523514

0 commit comments

Comments
 (0)