Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+19 -12
View File
@@ -11,43 +11,50 @@
namespace IPS\GeoLocation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use BadMethodCallException;
use IPS\GeoLocation\GeoCoder\Google;
use IPS\GeoLocation\GeoCoder\Mapbox;
use IPS\Settings;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* GeoCoder abstract class
*/
abstract class _GeoCoder
abstract class GeoCoder
{
/**
* @brief Cached GeoCoder instance
*/
protected static $instance = NULL;
protected static GeoCoder|null $instance = NULL;
/**
* Return instance of GeoCoder
*
* @return \IPS\GeoCoder
* @throws \BadMethodCallException
* @return GeoCoder|null
* @throws BadMethodCallException
*/
public static function i()
public static function i(): GeoCoder|null
{
if( static::$instance === NULL )
{
if ( \IPS\Settings::i()->googlemaps and \IPS\Settings::i()->google_maps_api_key )
if ( Settings::i()->googlemaps and Settings::i()->google_maps_api_key )
{
static::$instance = new \IPS\GeoLocation\GeoCoder\Google();
static::$instance = new Google();
}
elseif ( \IPS\Settings::i()->mapbox and \IPS\Settings::i()->mapbox_api_key )
elseif ( Settings::i()->mapbox and Settings::i()->mapbox_api_key )
{
static::$instance = new \IPS\GeoLocation\GeoCoder\Mapbox();
static::$instance = new Mapbox();
}
else
{
throw new \BadMethodCallException;
throw new BadMethodCallException;
}
}