Skip to content

Commit a53e3cf

Browse files
author
e1himself
committed
Simplify equals() code by returning result early
As of conversation with @j0k3r and @imiroslavov See https://github.com/LExpress/symfony1/pull/168/files/6152eda302f8d96bcc2f454d759bf124d3167fc6#r142346115
1 parent 6152eda commit a53e3cf

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

lib/vendor/lime/lime.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,17 +200,15 @@ public function ok($exp, $message = '')
200200
private function equals($exp1, $exp2)
201201
{
202202
if (is_object($exp1) || is_object($exp2)) {
203-
$value = $exp1 === $exp2;
203+
return $exp1 === $exp2;
204204
} else if (is_float($exp1) && is_float($exp2)) {
205-
$value = abs($exp1 - $exp2) < self::EPSILON;
205+
return abs($exp1 - $exp2) < self::EPSILON;
206206
} else if (is_string($exp1) && is_numeric($exp1) || is_string($exp2) && is_numeric($exp2)) {
207207
return $exp1 == $exp2;
208208
} else if (is_string($exp1) || is_string($exp2)) {
209209
return (string) $exp1 === (string) $exp2;
210-
} else {
211-
$value = $exp1 == $exp2;
212210
}
213-
return $value;
211+
return $exp1 == $exp2;
214212
}
215213

216214
/**

0 commit comments

Comments
 (0)