lthn.io/vendor/brick/math/src/Exception/NumberFormatException.php
Claude 48272c6072
feat: add Website modules — domain-scoped route registration
Website modules per CorePHP pattern:
- Website\Lethean: lthn.io homepage (domain: lthn.io)
- Website\Explorer: block explorer (domain: explorer.lthn.io)
- Website\Names: TLD registrar (domain: names.lthn.io)
- Website\Trade: DEX frontend (domain: trade.lthn.io)
- Website\Pool: mining pool (domain: pool.lthn.io)

Each binds to its subdomain via DomainResolving event and
falls back to path prefix (/explorer, /names, etc) on lthn.io.
Autoloader updated with Website\ namespace.

Co-Authored-By: Charon <charon@lethean.io>
2026-04-03 16:34:55 +01:00

60 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Brick\Math\Exception;
use function dechex;
use function ord;
use function sprintf;
use function strtoupper;
/**
* Exception thrown when attempting to create a number from a string with an invalid format.
*/
final class NumberFormatException extends MathException
{
/**
* @pure
*/
public static function invalidFormat(string $value): self
{
return new self(sprintf(
'The given value "%s" does not represent a valid number.',
$value,
));
}
/**
* @param string $char The failing character.
*
* @pure
*/
public static function charNotInAlphabet(string $char): self
{
return new self(sprintf(
'Character %s is not valid in the given alphabet.',
self::charToString($char),
));
}
/**
* @pure
*/
private static function charToString(string $char): string
{
$ord = ord($char);
if ($ord < 32 || $ord > 126) {
$char = strtoupper(dechex($ord));
if ($ord < 16) {
$char = '0' . $char;
}
return '0x' . $char;
}
return '"' . $char . '"';
}
}