function test_normalize() { $result = Bounds::normalize($this->sw, $this->ne); $this->assertEqual($result, new Bounds($this->sw, $this->ne)); $result = Bounds::normalize(array($this->sw, $this->ne)); $this->assertEqual($result, new Bounds($this->sw, $this->ne)); $result = Bounds::normalize(array($this->sw->get('lat'), $this->sw->get('lng')), array($this->ne->get('lat'), $this->ne->get('lng'))); $this->assertEqual($result, new Bounds($this->sw, $this->ne)); $result = Bounds::normalize(array(array($this->sw->get('lat'), $this->sw->get('lng')), array($this->ne->get('lat'), $this->ne->get('lng')))); $this->assertEqual($result, new Bounds($this->sw, $this->ne)); }
public static function castToBounds($input) { try { return Bounds::normalize($input); } catch (\InvalidArgumentException $e) { } try { $latLng = LatLng::normalize($input); return new Bounds($latLng, $latLng); } catch (\InvalidArgumentException $e) { } throw new \InvalidArgumentException(sprintf('Cannot cast to Bounds from input %s.', json_encode($input))); }
private function extract_bounds_from_options(&$options) { if (array_key_exists('bounds', $options)) { $bounds = $options['bounds']; array_delete($options, 'bounds'); return Bounds::normalize($bounds); } return null; }
public function testNormalizeShouldThrowExceptionForInvalidObjectInput() { $this->setExpectedException('\\InvalidArgumentException', 'Cannot normalize Bounds from input {}.'); Bounds::normalize(new \stdClass()); }