CoreFiles by mySites.guru
NumberFormatException.php41 lines, 969 bytes, from Joomla_5.2.3-Stable-Full_Package.zip
Raw History Compare with 5.2.2
md5
724ee6f5e4b8222af84343e020b4845f
sha1
e0803f818e47e176d9714cb8aa1984eb50ca4dc8
sha256
93c2bd2e19d4497f2b47102a0c4f4176d23e42b03b2983d4e3db0d7d3ffbd4e5
<?php

declare(strict_types=1);

namespace Brick\Math\Exception;

/**
 * Exception thrown when attempting to create a number from a string with an invalid format.
 */
class NumberFormatException extends MathException
{
    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.
     *
     * @psalm-pure
     */
    public static function charNotInAlphabet(string $char) : self
    {
        $ord = \ord($char);

        if ($ord < 32 || $ord > 126) {
            $char = \strtoupper(\dechex($ord));

            if ($ord < 10) {
                $char = '0' . $char;
            }
        } else {
            $char = '"' . $char . '"';
        }

        return new self(\sprintf('Char %s is not a valid character in the given alphabet.', $char));
    }
}

The same content is in 133 releases, Joomla 5.1.0-beta1 to 6.2.1-rc1. See them all, or every version of this file.