public function toBase(string $number, int $base) : string
    {
        $negative = ($number[0] === '-');

        if ($negative) {
            $number = \substr($number, 1);
        }

        $number = $this->toArbitraryBase($number, self::ALPHABET, $base);

        if ($negative) {
            return '-' . $number;
        }

        return $number;
    }
public function toBase(string $number, int $base) : string
    {
        $negative = ($number[0] === '-');

        if ($negative) {
            $number = \substr($number, 1);
        }

        $number = $this->toArbitraryBase($number, self::ALPHABET, $base);

        if ($negative) {
            return '-' . $number;
        }

        return $number;
    }
public function toBase ( string $ number , int $ base ) : string { $ negative = ( $ number [ 0 ] === '-' ) ; if ( $ negative ) { $ number = \ substr ( $ number , 1 ) ; } $ number = $ this -> toArbitraryBase ( $ number , self :: ALPHABET , $ base ) ; if ( $ negative ) { return '-' . $ number ; } return $ number ; }
Converts a number to an arbitrary base.

This method can be overridden by the concrete implementation if the underlying library
has built-in support for base conversion.

@param string $number The number to convert, following the Calculator conventions.
@param int    $base   The base to convert to, validated from 2 to 36.

@return string The converted number, lowercase.
Converts a number to an arbitrary base .