/** * @param mixed $y * * @return self * @throws InvalidValueException */ public function setY($y) { $parser = new Parser($y); try { $y = (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 ($y < -90 || $y > 90) { throw new InvalidValueException(sprintf('Invalid latitude value "%s", must be in range -90 to 90.', $y)); } $this->y = $y; return $this; }
/** * @param mixed $y * * @return self * @throws InvalidValueException */ public function setY($y) { $parser = new Parser($y); try { $y = (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 ($y < -90 || $y > 90) { throw InvalidValueException::invalidLatitude($y); } $this->y = $y; return $this; }
/** * @param string $input * @param string $exception * @param string $message * * @dataProvider dataSourceBad */ public function testBadValues($input, $exception, $message) { $this->setExpectedException($exception, $message); $parser = new Parser($input); $parser->parse(); }
/** * @param mixed $y * * @return self * @throws InvalidValueException */ public function setY($y) { $parser = new Parser($y); try { $this->y = (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()); } return $this; }