@@ -57,8 +57,7 @@ class VerEx {
57
57
*/
58
58
public function sanitize ($ value )
59
59
{
60
- if (!$ value )
61
- {
60
+ if (!$ value ) {
62
61
return $ value ;
63
62
}
64
63
return preg_quote ($ value , "/ " );
@@ -88,7 +87,7 @@ public function add($value)
88
87
* @param boolean $enable Enables or disables the line starting. Default value: true
89
88
* @return VerEx
90
89
*/
91
- public function startOfLine ($ enable= true )
90
+ public function startOfLine ($ enable = true )
92
91
{
93
92
$ this ->prefixes = $ enable ? "^ " : "" ;
94
93
return $ this ;
@@ -103,7 +102,7 @@ public function startOfLine($enable=true)
103
102
* @param boolean $enable Enables or disables the line ending. Default value: true
104
103
* @return VerEx
105
104
*/
106
- public function endOfLine ($ enable= true )
105
+ public function endOfLine ($ enable = true )
107
106
{
108
107
$ this ->suffixes = $ enable ? "$ " : "" ;
109
108
return $ this ;
@@ -171,7 +170,7 @@ public function anything()
171
170
* @param string $value The unaccepted chars
172
171
* @return VerEx
173
172
*/
174
- public function anythingBut ( $ value )
173
+ public function anythingBut ($ value )
175
174
{
176
175
$ this ->add ("([^ " . $ this ->sanitize ($ value ) ."]*) " );
177
176
return $ this ;
@@ -219,8 +218,7 @@ public function somethingBut($value)
219
218
public function replace ($ source , $ value )
220
219
{
221
220
// 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 ) {
224
222
$ this ->modifiers = str_replace ('g ' , '' , $ this ->modifiers );
225
223
return preg_replace ($ this ->getRegex (), $ value , $ source );
226
224
}
@@ -325,8 +323,7 @@ public function range()
325
323
326
324
$ arg_num = func_num_args ();
327
325
328
- if ($ arg_num %2 != 0 )
329
- {
326
+ if ($ arg_num %2 != 0 ) {
330
327
throw new Exception ("Number of args must be even " , 1 );
331
328
}
332
329
@@ -356,8 +353,7 @@ public function range()
356
353
*/
357
354
public function addModifier ($ modifier )
358
355
{
359
- if (strpos ($ this ->modifiers , $ modifier ) === false )
360
- {
356
+ if (strpos ($ this ->modifiers , $ modifier ) === false ) {
361
357
$ this ->modifiers .= $ modifier ;
362
358
}
363
359
@@ -389,14 +385,12 @@ public function removeModifier($modifier)
389
385
* @param boolean $enable Enables or disables case sensitive. Default true
390
386
* @return VerEx
391
387
*/
392
- public function withAnyCase ($ enable= true )
388
+ public function withAnyCase ($ enable = true )
393
389
{
394
- if ($ enable )
395
- {
390
+ if ($ enable ) {
396
391
$ this ->addModifier ('i ' );
397
392
}
398
- else
399
- {
393
+ else {
400
394
$ this ->removeModifier ('i ' );
401
395
}
402
396
@@ -412,14 +406,12 @@ public function withAnyCase($enable=true)
412
406
* @param boolean $enable Enables or disables g modifier. Default true
413
407
* @return VerEx
414
408
*/
415
- public function stopAtFirst ($ enable= true )
409
+ public function stopAtFirst ($ enable = true )
416
410
{
417
- if ($ enable )
418
- {
411
+ if ($ enable ) {
419
412
$ this ->addModifier ('g ' );
420
413
}
421
- else
422
- {
414
+ else {
423
415
$ this ->removeModifier ('g ' );
424
416
}
425
417
@@ -435,14 +427,12 @@ public function stopAtFirst($enable=true)
435
427
* @param boolean $enable Enables or disables m modifier. Default true
436
428
* @return VerEx
437
429
*/
438
- public function searchOneLine ($ enable= true )
430
+ public function searchOneLine ($ enable = true )
439
431
{
440
- if ($ enable ===true )
441
- {
432
+ if ($ enable ===true ) {
442
433
$ this ->addModifier ('m ' );
443
434
}
444
- else
445
- {
435
+ else {
446
436
$ this ->removeModifier ('m ' );
447
437
}
448
438
@@ -489,20 +479,17 @@ public function multiple($value)
489
479
*/
490
480
public function _or ($ value )
491
481
{
492
- if (strpos ($ this ->prefixes ,"( " )===false )
493
- {
482
+ if (strpos ($ this ->prefixes ,"( " )===false ) {
494
483
$ this ->prefixes .= "( " ;
495
484
}
496
485
497
- if (strpos ($ this ->suffixes , ") " )===false )
498
- {
486
+ if (strpos ($ this ->suffixes , ") " )===false ) {
499
487
$ this ->suffixes .= ") " ;
500
488
}
501
489
502
490
$ this ->add (")|( " );
503
491
504
- if ($ value )
505
- {
492
+ if ($ value ) {
506
493
$ this ->add ($ value );
507
494
}
508
495
@@ -547,8 +534,7 @@ public function getRegex()
547
534
public function test ($ value )
548
535
{
549
536
// 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 ) {
552
538
$ this ->modifiers = str_replace ('g ' , '' , $ this ->modifiers );
553
539
554
540
return preg_match_all ($ this ->getRegex (), $ value );
0 commit comments