Skip to content

Commit

Permalink
replace for loop with array_diff
Browse files Browse the repository at this point in the history
  • Loading branch information
melbahja committed Jun 14, 2018
1 parent 13a063a commit 5e0a10c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/Http/ServerRequest.php
Expand Up @@ -590,12 +590,8 @@ public function clientIp()
$n = count($addresses);

if ($trusted) {
for ($i = 1; $i < $n; $i++) {
if (in_array($addresses[$i], $this->trustedProxies) === false) {
$trusted = false;
break;
}
}
$trusted = array_diff($addresses, $this->trustedProxies);
$trusted = (count($trusted) === 1);
}

if ($trusted) {
Expand Down

0 comments on commit 5e0a10c

Please sign in to comment.