/** * Return new Number entity * * @param string $number * @return Entity\Number * @throws InvalidNumberException */ public function make($number) { if (!preg_match(self::NUMERIC_PATTERN, $number, $matches)) { throw new InvalidNumberException($number); } return new Entity\Number($this->integerFactory->make($matches['integer']), $this->decimalFactory->make(@$matches['fractional'])); }
/** * Return new ScientificNotation entity * * @param string $notation * @return ScientificNotation */ public function make($notation) { if (!preg_match(self::SCIENTIFIC_NOTATION_PATTERN, $notation, $matches)) { throw new InvalidScientificNotationException($notation); } $coefficient = $this->numberFactory->make($matches['coefficient']); $exponent = $this->integerFactory->make($matches['exponent']); return new ScientificNotation($coefficient, $exponent); }