ValueObjects\Geography\Coordinate::fromNative PHP Method

fromNative() public static method

Returns a new Coordinate object from native PHP arguments
public static fromNative ( ) : self
return self
    public static function fromNative()
    {
        $args = \func_get_args();
        if (\count($args) < 2 || \count($args) > 3) {
            throw new \BadMethodCallException('You must provide 2 to 3 arguments: 1) latitude, 2) longitude, 3) valid ellipsoid type (optional)');
        }
        $coordinate = new BaseCoordinate(array($args[0], $args[1]));
        $latitude = Latitude::fromNative($coordinate->getLatitude());
        $longitude = Longitude::fromNative($coordinate->getLongitude());
        $nativeEllipsoid = isset($args[2]) ? $args[2] : null;
        $ellipsoid = Ellipsoid::fromNative($nativeEllipsoid);
        return new static($latitude, $longitude, $ellipsoid);
    }

Usage Example

Example #1
0
 /** @expectedException \BadMethodCallException */
 public function testInvalidFromNative()
 {
     Coordinate::fromNative(40.829137);
 }