public static function geoCoordinate($value, array $options = [])
    {
        $options += [
            'format' => 'both',
            'type' => 'latLong'
        ];
        if ($options['type'] !== 'latLong') {
            throw new RuntimeException(sprintf(
                'Unsupported coordinate type "%s". Use "latLong" instead.',
                $options['type']
            ));
        }
        $pattern = '/^' . self::$_pattern['latitude'] . ',\s*' . self::$_pattern['longitude'] . '$/';
        if ($options['format'] === 'long') {
            $pattern = '/^' . self::$_pattern['longitude'] . '$/';
        }
        if ($options['format'] === 'lat') {
            $pattern = '/^' . self::$_pattern['latitude'] . '$/';
        }

        return (bool)preg_match($pattern, $value);
    }
public static function geoCoordinate($value, array $options = [])
    {
        $options += [
            'format' => 'both',
            'type' => 'latLong'
        ];
        if ($options['type'] !== 'latLong') {
            throw new RuntimeException(sprintf(
                'Unsupported coordinate type "%s". Use "latLong" instead.',
                $options['type']
            ));
        }
        $pattern = '/^' . self::$_pattern['latitude'] . ',\s*' . self::$_pattern['longitude'] . '$/';
        if ($options['format'] === 'long') {
            $pattern = '/^' . self::$_pattern['longitude'] . '$/';
        }
        if ($options['format'] === 'lat') {
            $pattern = '/^' . self::$_pattern['latitude'] . '$/';
        }

        return (bool)preg_match($pattern, $value);
    }
public static function geoCoordinate ( $ value , array $ options = [ ] ) { $ options += [ 'format' => 'both' , 'type' => 'latLong' ] ; if ( $ options [ 'type' ] !== 'latLong' ) { throw new RuntimeException ( sprintf ( 'Unsupported coordinate type "%s". Use "latLong" instead.' , $ options [ 'type' ] ) ) ; } $ pattern = '/^' . self :: $ _pattern [ 'latitude' ] . ',\s*' . self :: $ _pattern [ 'longitude' ] . '$/' ; if ( $ options [ 'format' ] === 'long' ) { $ pattern = '/^' . self :: $ _pattern [ 'longitude' ] . '$/' ; } if ( $ options [ 'format' ] === 'lat' ) { $ pattern = '/^' . self :: $ _pattern [ 'latitude' ] . '$/' ; } return ( bool ) preg_match ( $ pattern , $ value ) ; }
Validates a geographic coordinate.

Supported formats:

- `<latitude>, <longitude>` Example: `-25.274398, 133.775136`

### Options

- `type` - A string of the coordinate format, right now only `latLong`.
- `format` - By default `both`, can be `long` and `lat` as well to validate
only a part of the coordinate.

@param string $value Geographic location as string
@param array $options Options for the validation logic.
@return bool
Validates a geographic coordinate .