Skip to content

Commit

Permalink
Get rid of redundant array_key_exists
Browse files Browse the repository at this point in the history
  • Loading branch information
oschwald committed Nov 15, 2024
1 parent ecd4712 commit 99c623b
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/MinFraud.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,21 @@ public function withDevice(
}
$acceptLanguage = $this->remove($values, 'accept_language');
$ipAddress = $this->remove($values, 'ip_address');
if (\array_key_exists('session_age', $values)) {
$v = $this->remove($values, 'session_age', ['double', 'float', 'integer', 'string']);
if ($v !== null) {
if (!is_numeric($v)) {
$this->maybeThrowInvalidInputException('Expected session_age to be a number');
}
$sessionAge = (float) $v;

$v = $this->remove($values, 'session_age', ['double', 'float', 'integer', 'string']);
if ($v !== null) {
if (!is_numeric($v)) {
$this->maybeThrowInvalidInputException('Expected session_age to be a number');
}
$sessionAge = (float) $v;
}
if (\array_key_exists('session_id', $values)) {
$v = $this->remove($values, 'session_id', ['integer', 'string']);
if ($v !== null) {
$sessionId = (string) $v;
}


$v = $this->remove($values, 'session_id', ['integer', 'string']);
if ($v !== null) {
$sessionId = (string) $v;
}

$userAgent = $this->remove($values, 'user_agent');

$this->verifyEmpty($values);
Expand Down Expand Up @@ -1279,12 +1279,12 @@ public function withShoppingCartItem(
}

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

$v = $this->remove($values, 'item_id', ['integer', 'string']);
if ($v !== null) {
$itemId = (string) $v;
}

$price = $this->remove($values, 'price', ['double', 'float', 'integer']);
$quantity = $this->remove($values, 'quantity', ['integer']);

Expand Down

0 comments on commit 99c623b

Please sign in to comment.