/** * Creates a DecimalValue from a given string. * * The decimal notation for the value is based on ISO 31-0, with some modifications: * - the decimal separator is '.' (period). Comma is not used anywhere. * - leading and trailing as well as any internal whitespace is ignored * - the following characters are ignored: comma (","), apostrophe ("'"). * - scientific (exponential) notation is supported using the pattern /e[-+]\d+/ * - the number may start (or end) with a decimal point. * - leading zeroes are stripped, except directly before the decimal point * - trailing zeroes are stripped, except directly after the decimal point * - zero is always positive. * * @see StringValueParser::stringParse * * @since 0.1 * * @param string $value * * @return DecimalValue * @throws ParseException */ protected function stringParse($value) { $rawValue = $value; $value = $this->unlocalizer->unlocalizeNumber($value); //handle scientific notation list($value, $exponent) = $this->splitDecimalExponent($value); $value = $this->normalizeDecimal($value); if ($value === '') { throw new ParseException('Decimal value must not be empty', $rawValue, self::FORMAT_NAME); } try { $decimal = new DecimalValue($value); $decimal = $this->applyDecimalExponent($decimal, $exponent); return $decimal; } catch (IllegalValueException $ex) { throw new ParseException($ex->getMessage(), $rawValue, self::FORMAT_NAME); } }