public static function fromString(string $input): self
    {
        $input = preg_replace('/[^\d]/', '', $input);

        if (!is_numeric($input)) {
            throw new \InvalidArgumentException("Expects \$input to be a number, \"{$input}\" given.");
        }

        // Get the last digit.
        $checkDigit = (int) $input[strlen($input) - 1];

        // Remove the last digit.
        $number = substr($input, 0, strlen($input) - 1);

        return new self($number, $checkDigit);
    }
public static function fromString(string $input): self
    {
        $input = preg_replace('/[^\d]/', '', $input);

        if (!is_numeric($input)) {
            throw new \InvalidArgumentException("Expects \$input to be a number, \"{$input}\" given.");
        }

        // Get the last digit.
        $checkDigit = (int) $input[strlen($input) - 1];

        // Remove the last digit.
        $number = substr($input, 0, strlen($input) - 1);

        return new self($number, $checkDigit);
    }
public static function fromString ( string $ input ) : self { $ input = preg_replace ( '/[^\d]/' , '' , $ input ) ; if ( ! is_numeric ( $ input ) ) { throw new \ InvalidArgumentException ( "Expects \$input to be a number, \"{$input}\" given." ) ; } // Get the last digit. $ checkDigit = ( int ) $ input [ strlen ( $ input ) - 1 ] ; // Remove the last digit. $ number = substr ( $ input , 0 , strlen ( $ input ) - 1 ) ; return new self ( $ number , $ checkDigit ) ; }
Create a new number from an input that contains the check digit
already.

@param string $input The input that contains the check digit already.

@return self
Create a new number from an input that contains the check digit already .