Skip to content

Commit

Permalink
Improve package namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Aug 3, 2023
1 parent a45c213 commit 44f3e3e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
8 changes: 4 additions & 4 deletions BaseUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use JsonSerializable;
use League\Uri\Contracts\UriAccess;
use League\Uri\Contracts\UriInterface;
use League\Uri\IPv4\IPv4Converter;
use League\Uri\IPv4\MissingIPv4Calculator;
use League\Uri\IPv4\Converter;
use League\Uri\IPv4\MissingCalculator;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Http\Message\UriInterface as Psr7UriInterface;
use Stringable;
Expand Down Expand Up @@ -432,8 +432,8 @@ private static function formatHost(Psr7UriInterface|UriInterface $uri): Psr7UriI
{
$host = $uri->getHost();
try {
$converted = IPv4Converter::fromEnvironment()($host);
} catch (MissingIPv4Calculator) {
$converted = Converter::fromEnvironment()($host);
} catch (MissingCalculator) {
$converted = null;
}

Expand Down
15 changes: 7 additions & 8 deletions Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
use League\Uri\Contracts\UriException;
use League\Uri\Contracts\UriInterface;
use League\Uri\Exceptions\FileinfoSupportMissing;
use League\Uri\Exceptions\IdnaConversionFailed;
use League\Uri\Exceptions\IdnSupportMissing;
use League\Uri\Exceptions\SyntaxError;
use League\Uri\Idna\ConversionFailed;
use League\Uri\Idna\Idna;
use League\Uri\UriTemplate\TemplateCanNotBeExpanded;
use Psr\Http\Message\UriInterface as Psr7UriInterface;
Expand Down Expand Up @@ -332,17 +331,17 @@ private function formatHost(?string $host): ?string
*
* The host is converted to its ascii representation if needed
*
* @throws IdnSupportMissing if the submitted host required missing or misconfigured IDN support
* @throws SyntaxError if the submitted host is not a valid registered name
* @throws \League\Uri\Idna\MissingSupport if the submitted host required missing or misconfigured IDN support
* @throws SyntaxError if the submitted host is not a valid registered name
*/
private function formatRegisteredName(string $host): string
{
$formatter = static function (string $host) {
$info = Idna::toAscii($host);
$result = Idna::toAscii($host);

return match (true) {
$info->hasErrors() => throw IdnaConversionFailed::dueToIDNAError($host, $info),
default => $info->domain(),
$result->hasErrors() => throw ConversionFailed::dueToError($host, $result),
default => $result->domain(),
};
};
$formattedHost = rawurldecode($host);
Expand Down Expand Up @@ -435,7 +434,7 @@ public static function new(Stringable|string $uri = ''): self
*/
public static function fromBaseUri(Stringable|string $uri, Stringable|string|null $baseUri = null): self
{
$uri = self::new((string) $uri);
$uri = self::new($uri);
$baseUri = BaseUri::from($baseUri ?? $uri);

/** @var self $uri */
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@
"league/uri-schemes": "^1.0"
},
"suggest": {
"ext-bcmath": "to improve IPV4 host parsing",
"ext-fileinfo": "to create Data URI from file contennts",
"ext-gmp": "to improve IPV4 host parsing",
"ext-intl": "to handle IDN host with the best performance",
"ext-gmp": "to improve handle IPV4 parsing",
"ext-bcmath": "to improve handle IPV4 parsing",
"ext-fileinfo": "to create Data URI from a filepath",
"jeremykendall/php-domain-parser": "to resolve Public Suffix and Top Level Domain",
"league/uri-components" : "Needed to easily manipulate URI objects",
"php-64bit": "to improve handle IPV4 parsing",
"symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is missing"
"league/uri-components" : "Needed to easily manipulate URI objects components",
"php-64bit": "to improve IPV4 host parsing",
"symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present"
},
"extra": {
"branch-alias": {
Expand Down

0 comments on commit 44f3e3e

Please sign in to comment.