From 2496764d478978ffdeb956f87936781843aaf6a4 Mon Sep 17 00:00:00 2001 From: Daniel Noel-Davies Date: Fri, 20 Oct 2017 16:25:55 +0100 Subject: [PATCH] Use early returns in else method Then when method should be using early returns instead of if/else --- src/Illuminate/Support/Collection.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Support/Collection.php b/src/Illuminate/Support/Collection.php index 13898792cbbd..df5a4e256e67 100644 --- a/src/Illuminate/Support/Collection.php +++ b/src/Illuminate/Support/Collection.php @@ -432,7 +432,9 @@ public function when($value, callable $callback, callable $default = null) { if ($value) { return $callback($this); - } elseif ($default) { + } + + if ($default) { return $default($this); }