/** * {@inheritdoc} */ public function setX($x) { $x = $this->toFloat($x); if ($x < -180 || $x > 180) { throw InvalidValueException::invalidLongitude($x); } $this->x = $x; return $this; }
/** * @param mixed $x * * @return self * @throws InvalidValueException */ public function setX($x) { $parser = new Parser($x); try { $x = (double) $parser->parse(); } catch (RangeException $e) { throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); } catch (UnexpectedValueException $e) { throw new InvalidValueException($e->getMessage(), $e->getCode(), $e->getPrevious()); } if ($x < -180 || $x > 180) { throw InvalidValueException::invalidLongitude($x); } $this->x = $x; return $this; }