From ebb9bf8a368ecc255de92c7e328a2d331b5e709d Mon Sep 17 00:00:00 2001 From: Peter van Westen Date: Tue, 2 May 2017 11:54:44 +0200 Subject: [PATCH] [5.4] Refactors if structure in ConfirmableTrait::confirmToProceed Refactors the `if` structure in `ConfirmableTrait::confirmToProceed` by using an early return. This reduces the indentation and improves readability. --- src/Illuminate/Console/ConfirmableTrait.php | 22 +++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Illuminate/Console/ConfirmableTrait.php b/src/Illuminate/Console/ConfirmableTrait.php index 7172215303ab..9801ed795513 100644 --- a/src/Illuminate/Console/ConfirmableTrait.php +++ b/src/Illuminate/Console/ConfirmableTrait.php @@ -21,20 +21,22 @@ public function confirmToProceed($warning = 'Application In Production!', $callb $shouldConfirm = $callback instanceof Closure ? call_user_func($callback) : $callback; - if ($shouldConfirm) { - if ($this->option('force')) { - return true; - } + if (! $shouldConfirm) { + return true; + } + + if ($this->option('force')) { + return true; + } - $this->alert($warning); + $this->alert($warning); - $confirmed = $this->confirm('Do you really wish to run this command?'); + $confirmed = $this->confirm('Do you really wish to run this command?'); - if (! $confirmed) { - $this->comment('Command Cancelled!'); + if (! $confirmed) { + $this->comment('Command Cancelled!'); - return false; - } + return false; } return true;