Skip to content

Commit

Permalink
Remove new methods from BaseUri as BaseUri is being deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Dec 31, 2024
1 parent 9670d99 commit 6e5d498
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
28 changes: 1 addition & 27 deletions BaseUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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<string,int> */
final protected const WHATWG_SPECIAL_SCHEMES = ['ftp' => 1, 'http' => 1, 'https' => 1, 'ws' => 1, 'wss' => 1];
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6e5d498

Please sign in to comment.