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

@@ -12,21 +12,25 @@
namespace IPS\nexus\Fraud\MaxMind;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use function defined;
use function in_array;
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;
}
/**
* MaxMind Response
*/
class _Response
class Response
{
/**
* @brief Data
*/
protected $data = array();
protected array $data = array();
/**
* Constructor
@@ -34,7 +38,7 @@ class _Response
* @param string|NULL $data Data from MaxMind
* @return void
*/
public function __construct( $data = NULL )
public function __construct( ?string $data = NULL )
{
if ( $data )
{
@@ -48,17 +52,12 @@ class _Response
* @param string $key Key
* @return mixed
*/
public function __get( $key )
public function __get( string $key )
{
if ( isset( $this->data[ $key ] ) )
{
return $this->data[ $key ];
}
/* They changed their API, this is a less fragile and backwards compatible way to do this */
else if( $key == 'riskScore' and isset( $this->data[ 'risk_score' ] ) )
{
return $this->data[ 'risk_score' ];
}
return NULL;
}
@@ -66,9 +65,9 @@ class _Response
* Build from JSON
*
* @param string $json JSON data
* @return \IPS\nexus\Fraud\MaxMind\Response
* @return static
*/
public static function buildFromJson( $json )
public static function buildFromJson( string $json ) : static
{
$obj = new static;
$obj->data = json_decode( $json, TRUE );
@@ -90,7 +89,7 @@ class _Response
*
* @return int
*/
public function proxyScorePercentage()
public function proxyScorePercentage() : int
{
return ( 100 - 10 ) / 3 * $this->proxyScore + ( $this->proxyScore > 3 ? ( 10 * ( $this->proxyScore - 3 ) ) : 0 );
}
@@ -106,9 +105,9 @@ class _Response
*
* @return bool
*/
public function error()
public function error() : bool
{
if ( $this->error AND \in_array( $this->code, static::$responseErrors ) )
if ( $this->error AND in_array( $this->code, static::$responseErrors ) )
{
return TRUE;
}
@@ -120,9 +119,9 @@ class _Response
*
* @return bool
*/
public function warning()
public function warning() : bool
{
if ( $this->error AND !\in_array($this->code, static::$responseErrors ) )
if ( $this->error AND !in_array($this->code, static::$responseErrors ) )
{
return TRUE;
}