Skip to content

Commit

Permalink
Use array_key_exists instead of isset
Browse files Browse the repository at this point in the history
For better handling of null values.
  • Loading branch information
oschwald committed Nov 15, 2024
1 parent 915c91c commit b4a9212
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/MinFraud.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function withDevice(
}
$acceptLanguage = $this->remove($values, 'accept_language');
$ipAddress = $this->remove($values, 'ip_address');
if (isset($values['session_age'])) {
if (\array_key_exists('session_age', $values)) {
$v = $this->remove($values, 'session_age', ['double', 'float', 'integer', 'string']);
if ($v !== null) {
if (!is_numeric($v)) {
Expand All @@ -210,7 +210,7 @@ public function withDevice(
$sessionAge = (float) $v;
}
}
if (isset($values['session_id'])) {
if (\array_key_exists('session_id', $values)) {
$v = $this->remove($values, 'session_id', ['integer', 'string']);
if ($v !== null) {
$sessionId = (string) $v;
Expand Down Expand Up @@ -1279,7 +1279,7 @@ public function withShoppingCartItem(
}

$category = $this->remove($values, 'category');
if (isset($values['item_id'])) {
if (\array_key_exists('item_id', $values)) {
$v = $this->remove($values, 'item_id', ['integer', 'string']);
if ($v !== null) {
$itemId = (string) $v;
Expand Down

0 comments on commit b4a9212

Please sign in to comment.