/**
  * Magic method to allow methods that are not specifically defined.
  *
  * This is where we look to see if the class that we are proxing has the method that is being called, and if it
  * does, then pass the call to the class under proxy.  If a method is defined in our class, then it gets called
  * first, so you can "extend" the classes by defining methods that overwrite the "parent" there.
  *
  * @param string $name
  * @param array  $arguments
  *
  * @return mixed
  * @throws InvalidArgumentException
  */
 public function __call($name, $arguments)
 {
     // Sugar to make to<Format>() work
     if (preg_match("/^to([A-Z][A-z]*)/u", $name, $parts) && 0 === count($arguments)) {
         return $this->geometry->out($this->mapper->map($parts[1]));
     }
     // Call the method on the class being proxied
     if (method_exists($this->geometry, $name)) {
         return call_user_func_array([$this->geometry, $name], $arguments);
     }
     throw new RuntimeException(sprintf("Call to undefined method %s::%s().", __CLASS__, $name));
 }
Example #2
0
 /**
  * Call geoPHP to load the data.
  *
  * @param string|object $data
  * @param string|null   $type
  *
  * @return bool|\GeometryCollection|mixed
  * @throws Exception
  */
 protected function loadGeometry($data, $type)
 {
     if (is_null($type)) {
         return $this->geoPhp->load($data);
     }
     return $this->geoPhp->load($data, $this->mapper->map($type));
 }