Skip to content

Commit

Permalink
Improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Aug 4, 2023
1 parent ce1c662 commit 1ef7c9d
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions Idna/ConversionFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1ef7c9d

Please sign in to comment.