From 5f0c27210f4f1f9ad77ad74d8382603da193b56c Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sun, 11 Aug 2013 15:23:55 +0100 Subject: [PATCH] reducing function bodies to ternary returns --- VerbalExpressions.php | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/VerbalExpressions.php b/VerbalExpressions.php index 8bfeb9df..31ea6fc6 100644 --- a/VerbalExpressions.php +++ b/VerbalExpressions.php @@ -372,14 +372,7 @@ public function removeModifier($modifier) */ public function withAnyCase($enable = true) { - if($enable) { - $this->addModifier('i'); - } - else { - $this->removeModifier('i'); - } - - return $this; + return $enable ? $this->addModifier('i') : $this->removeModifier('i'); } /** @@ -393,14 +386,7 @@ public function withAnyCase($enable = true) */ public function stopAtFirst($enable = true) { - if($enable) { - $this->addModifier('g'); - } - else { - $this->removeModifier('g'); - } - - return $this; + return $enable ? $this->addModifier('g') : $this->removeModifier('g'); } /** @@ -414,14 +400,7 @@ public function stopAtFirst($enable = true) */ public function searchOneLine($enable = true) { - if($enable===true) { - $this->addModifier('m'); - } - else { - $this->removeModifier('m'); - } - - return $this; + return $enable ? $this->addModifier('m') : $this->removeModifier('m'); } /**