Skip to content

Commit

Permalink
reducing function bodies to ternary returns
Browse files Browse the repository at this point in the history
  • Loading branch information
SignpostMarv committed Aug 11, 2013
1 parent 98067f3 commit 5f0c272
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions VerbalExpressions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand All @@ -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');
}

/**
Expand Down

0 comments on commit 5f0c272

Please sign in to comment.