Skip to content

Commit 78d90aa

Browse files
author
William Knauss
committed
some prs improvments
1 parent 7f8cc22 commit 78d90aa

File tree

1 file changed

+20
-34
lines changed

1 file changed

+20
-34
lines changed

VerbalExpressions.php

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ class VerEx {
5757
*/
5858
public function sanitize($value)
5959
{
60-
if(!$value)
61-
{
60+
if(!$value) {
6261
return $value;
6362
}
6463
return preg_quote($value, "/");
@@ -88,7 +87,7 @@ public function add($value)
8887
* @param boolean $enable Enables or disables the line starting. Default value: true
8988
* @return VerEx
9089
*/
91-
public function startOfLine($enable=true)
90+
public function startOfLine($enable = true)
9291
{
9392
$this->prefixes = $enable ? "^" : "";
9493
return $this;
@@ -103,7 +102,7 @@ public function startOfLine($enable=true)
103102
* @param boolean $enable Enables or disables the line ending. Default value: true
104103
* @return VerEx
105104
*/
106-
public function endOfLine($enable=true)
105+
public function endOfLine($enable = true)
107106
{
108107
$this->suffixes = $enable ? "$" : "";
109108
return $this;
@@ -171,7 +170,7 @@ public function anything()
171170
* @param string $value The unaccepted chars
172171
* @return VerEx
173172
*/
174-
public function anythingBut( $value )
173+
public function anythingBut($value)
175174
{
176175
$this->add("([^". $this->sanitize($value) ."]*)");
177176
return $this;
@@ -219,8 +218,7 @@ public function somethingBut($value)
219218
public function replace($source, $value)
220219
{
221220
// php doesn't have g modifier so we remove it if it's there and we remove limit param
222-
if(strpos($this->modifiers, 'g') !== false)
223-
{
221+
if (strpos($this->modifiers, 'g') !== false) {
224222
$this->modifiers = str_replace('g', '', $this->modifiers);
225223
return preg_replace($this->getRegex(), $value, $source);
226224
}
@@ -325,8 +323,7 @@ public function range()
325323

326324
$arg_num = func_num_args();
327325

328-
if($arg_num%2 != 0)
329-
{
326+
if($arg_num%2 != 0) {
330327
throw new Exception("Number of args must be even", 1);
331328
}
332329

@@ -356,8 +353,7 @@ public function range()
356353
*/
357354
public function addModifier($modifier)
358355
{
359-
if(strpos($this->modifiers, $modifier) === false)
360-
{
356+
if(strpos($this->modifiers, $modifier) === false) {
361357
$this->modifiers .= $modifier;
362358
}
363359

@@ -389,14 +385,12 @@ public function removeModifier($modifier)
389385
* @param boolean $enable Enables or disables case sensitive. Default true
390386
* @return VerEx
391387
*/
392-
public function withAnyCase($enable=true)
388+
public function withAnyCase($enable = true)
393389
{
394-
if($enable)
395-
{
390+
if($enable) {
396391
$this->addModifier('i');
397392
}
398-
else
399-
{
393+
else {
400394
$this->removeModifier('i');
401395
}
402396

@@ -412,14 +406,12 @@ public function withAnyCase($enable=true)
412406
* @param boolean $enable Enables or disables g modifier. Default true
413407
* @return VerEx
414408
*/
415-
public function stopAtFirst($enable=true)
409+
public function stopAtFirst($enable = true)
416410
{
417-
if($enable)
418-
{
411+
if($enable) {
419412
$this->addModifier('g');
420413
}
421-
else
422-
{
414+
else {
423415
$this->removeModifier('g');
424416
}
425417

@@ -435,14 +427,12 @@ public function stopAtFirst($enable=true)
435427
* @param boolean $enable Enables or disables m modifier. Default true
436428
* @return VerEx
437429
*/
438-
public function searchOneLine($enable=true)
430+
public function searchOneLine($enable = true)
439431
{
440-
if($enable===true)
441-
{
432+
if($enable===true) {
442433
$this->addModifier('m');
443434
}
444-
else
445-
{
435+
else {
446436
$this->removeModifier('m');
447437
}
448438

@@ -489,20 +479,17 @@ public function multiple($value)
489479
*/
490480
public function _or($value)
491481
{
492-
if(strpos($this->prefixes,"(")===false)
493-
{
482+
if(strpos($this->prefixes,"(")===false) {
494483
$this->prefixes .= "(";
495484
}
496485

497-
if(strpos($this->suffixes, ")")===false)
498-
{
486+
if(strpos($this->suffixes, ")")===false) {
499487
$this->suffixes .= ")";
500488
}
501489

502490
$this->add(")|(");
503491

504-
if($value)
505-
{
492+
if($value) {
506493
$this->add($value);
507494
}
508495

@@ -547,8 +534,7 @@ public function getRegex()
547534
public function test($value)
548535
{
549536
// php doesn't have g modifier so we remove it if it's there and call preg_match_all()
550-
if(strpos($this->modifiers, 'g') !== false)
551-
{
537+
if(strpos($this->modifiers, 'g') !== false) {
552538
$this->modifiers = str_replace('g', '', $this->modifiers);
553539

554540
return preg_match_all($this->getRegex(), $value);

0 commit comments

Comments
 (0)