From 1ef7c9d2ed5c711afa33d67323b8c8919fe404fc Mon Sep 17 00:00:00 2001 From: ignace nyamagana butera Date: Fri, 4 Aug 2023 17:28:27 +0200 Subject: [PATCH] Improve documentation --- Idna/ConversionFailed.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/Idna/ConversionFailed.php b/Idna/ConversionFailed.php index d21dc37..e09ff96 100644 --- a/Idna/ConversionFailed.php +++ b/Idna/ConversionFailed.php @@ -17,27 +17,19 @@ final class ConversionFailed extends SyntaxError { - private function __construct(string $message, private readonly ?Result $result = null) + private function __construct(string $message, private readonly Result $result) { parent::__construct($message); } - public static function dueToError(string $domain, Result $result): self + public static function dueToError(string $host, Result $result): self { - $info = array_map(fn (Error $error): string => $error->description(), $result->errors()); + $reasons = array_map(fn (Error $error): string => $error->description(), $result->errors()); - return new self( - 'The host `'.$domain.'` is invalid : '.implode(', ', $info).' .', - $result - ); + return new self('The host `'.$host.'` could not be converted: '.implode('; ', $reasons).' .', $result); } - public static function dueToInvalidHost(string $domain): self - { - return new self('The host `'.$domain.'` is not a valid IDN host'); - } - - public function result(): ?Result + public function result(): Result { return $this->result; }