Skip to content

Commit 5f0c272

Browse files
committed
reducing function bodies to ternary returns
1 parent 98067f3 commit 5f0c272

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

VerbalExpressions.php

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -372,14 +372,7 @@ public function removeModifier($modifier)
372372
*/
373373
public function withAnyCase($enable = true)
374374
{
375-
if($enable) {
376-
$this->addModifier('i');
377-
}
378-
else {
379-
$this->removeModifier('i');
380-
}
381-
382-
return $this;
375+
return $enable ? $this->addModifier('i') : $this->removeModifier('i');
383376
}
384377

385378
/**
@@ -393,14 +386,7 @@ public function withAnyCase($enable = true)
393386
*/
394387
public function stopAtFirst($enable = true)
395388
{
396-
if($enable) {
397-
$this->addModifier('g');
398-
}
399-
else {
400-
$this->removeModifier('g');
401-
}
402-
403-
return $this;
389+
return $enable ? $this->addModifier('g') : $this->removeModifier('g');
404390
}
405391

406392
/**
@@ -414,14 +400,7 @@ public function stopAtFirst($enable = true)
414400
*/
415401
public function searchOneLine($enable = true)
416402
{
417-
if($enable===true) {
418-
$this->addModifier('m');
419-
}
420-
else {
421-
$this->removeModifier('m');
422-
}
423-
424-
return $this;
403+
return $enable ? $this->addModifier('m') : $this->removeModifier('m');
425404
}
426405

427406
/**

0 commit comments

Comments
 (0)