Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
 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)));
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 public function testNormalizeShouldThrowExceptionForInvalidObjectInput()
 {
     $this->setExpectedException('\\InvalidArgumentException', 'Cannot normalize Bounds from input {}.');
     Bounds::normalize(new \stdClass());
 }