diff --git a/uri/BaseUri.php b/uri/BaseUri.php index c24240da..b276d317 100644 --- a/uri/BaseUri.php +++ b/uri/BaseUri.php @@ -15,7 +15,6 @@ use Deprecated; use JsonSerializable; -use League\Uri\Contracts\Conditionable; use League\Uri\Contracts\UriAccess; use League\Uri\Contracts\UriInterface; use League\Uri\Exceptions\MissingFeature; @@ -25,7 +24,6 @@ use Psr\Http\Message\UriFactoryInterface; use Psr\Http\Message\UriInterface as Psr7UriInterface; use Stringable; -use Throwable; use function array_map; use function array_pop; @@ -35,7 +33,6 @@ use function explode; use function implode; use function in_array; -use function is_bool; use function preg_match; use function rawurldecode; use function str_repeat; @@ -46,7 +43,7 @@ /** * @phpstan-import-type ComponentMap from UriInterface */ -class BaseUri implements Stringable, JsonSerializable, UriAccess, Conditionable +class BaseUri implements Stringable, JsonSerializable, UriAccess { /** @var array */ final protected const WHATWG_SPECIAL_SCHEMES = ['ftp' => 1, 'http' => 1, 'https' => 1, 'ws' => 1, 'wss' => 1]; @@ -73,15 +70,6 @@ public static function from(Stringable|string $uri, ?UriFactoryInterface $uriFac return new static(static::formatHost(static::filterUri($uri, $uriFactory)), $uriFactory); } - public static function tryFrom(Stringable|string $uri, ?UriFactoryInterface $uriFactory = null): ?static - { - try { - return self::from($uri, $uriFactory); - } catch (Throwable) { - return null; - } - } - public function withUriFactory(UriFactoryInterface $uriFactory): static { return new static($this->uri, $uriFactory); @@ -344,20 +332,6 @@ public function relativize(Stringable|string $uri): static $this->uriFactory ); } - - final public function when(callable|bool $condition, callable $onSuccess, ?callable $onFail = null): static - { - if (!is_bool($condition)) { - $condition = $condition($this); - } - - return match (true) { - $condition => $onSuccess($this), - null !== $onFail => $onFail($this), - default => $this, - } ?? $this; - } - final protected function computeOrigin(Psr7UriInterface|UriInterface $uri, ?string $nullValue): Psr7UriInterface|UriInterface|null { $scheme = $uri->getScheme(); diff --git a/uri/CHANGELOG.md b/uri/CHANGELOG.md index a7638591..efca090b 100644 --- a/uri/CHANGELOG.md +++ b/uri/CHANGELOG.md @@ -9,8 +9,6 @@ All Notable changes to `League\Uri` will be documented in this file - Added methods to align with the upcoming `Uri\Rfc3986Uri` PHP native class (see: https://wiki.php.net/rfc/url_parsing_api#proposal) - `Uri::tryNew` returns a new `Uri` instance on success or null on failure (ie: a Relax version of `Uri::new`). - `Http::tryNew` returns a new `Uri` instance on success or null on failure (ie: a Relax version of `Http::new`). -- `BaseUri::tryfrom` returns a new `BaseUri` instance on success or null on failure (ie: a Relax version of `BaseUri::from`). -- `BaseUri::when` conditional method to ease component building logic. - `Http::when` conditional method to ease component building logic. - `Uri::when` conditional method to ease component building logic. - `Uri` implements the new `League\Uri\Contract\UriInspector` interface