Files
assets
data
dependencies
amphp
berlindb
composer
daverandom
delight-im
doctrine
guzzlehttp
hashids
ifsnop
jasny
kelunik
league
uri
uri-interfaces
Contracts
Exceptions
ConversionFailed.php
MissingFeature.php
OffsetOutOfBounds.php
SyntaxError.php
IPv4
Idna
KeyValuePair
Encoder.php
FeatureDetection.php
QueryString.php
UriString.php
uri-parser
mexitek
mpdf
myclabs
nesbot
nyholm
pablo-sg-pacheco
paragonie
phpdocumentor
phpseclib
phpstan
psr
rakit
ralouphie
remotelyliving
rpnzl
scssphp
setasign
spatie
stripe
symfony
webmozart
woocommerce
yahnis-elsts
autoload.php
scoper-autoload.php
inc
lang
views
.gitignore
LICENSE
autoload.php
composer.json
constants.php
loco.xml
readme.txt
sunrise.php
uninstall.php
wp-multisite-waas.php
wp-multisite-waas/dependencies/league/uri-interfaces/Exceptions/ConversionFailed.php
2024-11-30 18:24:12 -07:00

37 lines
1.1 KiB
PHP

<?php
/**
* League.Uri (https://uri.thephpleague.com)
*
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace WP_Ultimo\Dependencies\League\Uri\Exceptions;
use WP_Ultimo\Dependencies\League\Uri\Idna\Error;
use WP_Ultimo\Dependencies\League\Uri\Idna\Result;
use Stringable;
final class ConversionFailed extends SyntaxError
{
private function __construct(string $message, private readonly string $host, private readonly Result $result)
{
parent::__construct($message);
}
public static function dueToIdnError(Stringable|string $host, Result $result) : self
{
$reasons = \array_map(fn(Error $error): string => $error->description(), $result->errors());
return new self('Host `' . $host . '` is invalid: ' . \implode('; ', $reasons) . '.', (string) $host, $result);
}
public function getHost() : string
{
return $this->host;
}
public function getResult() : Result
{
return $this->result;
}
}