10
10
11
11
class VerbalExpressions
12
12
{
13
- public $ prefixes = "" ;
14
- public $ source = "" ;
15
- public $ suffixes = "" ;
16
- public $ modifiers = " m " ; // default to global multi line matching
13
+ public $ prefixes = '' ;
14
+ public $ source = '' ;
15
+ public $ suffixes = '' ;
16
+ public $ modifiers = ' m ' ; // default to global multi line matching
17
17
public $ replaceLimit = 1 ; // the limit of preg_replace when g modifier is not set
18
18
protected $ lastAdded = false ; // holds the last added regex
19
19
@@ -28,7 +28,7 @@ class VerbalExpressions
28
28
*/
29
29
public static function sanitize ($ value )
30
30
{
31
- return $ value ? preg_quote ($ value , " / " ) : $ value ;
31
+ return $ value ? preg_quote ($ value , ' / ' ) : $ value ;
32
32
}
33
33
34
34
/**
@@ -58,7 +58,7 @@ public function add($value)
58
58
*/
59
59
public function startOfLine ($ enable = true )
60
60
{
61
- $ this ->prefixes = $ enable ? " ^ " : "" ;
61
+ $ this ->prefixes = $ enable ? ' ^ ' : '' ;
62
62
63
63
return $ this ;
64
64
}
@@ -74,7 +74,7 @@ public function startOfLine($enable = true)
74
74
*/
75
75
public function endOfLine ($ enable = true )
76
76
{
77
- $ this ->suffixes = $ enable ? " $ " : "" ;
77
+ $ this ->suffixes = $ enable ? ' $ ' : '' ;
78
78
79
79
return $ this ;
80
80
}
@@ -90,7 +90,7 @@ public function endOfLine($enable = true)
90
90
*/
91
91
public function then ($ value )
92
92
{
93
- return $ this ->add (" (?: " . self ::sanitize ($ value ) . " ) " );
93
+ return $ this ->add (' (?: ' . self ::sanitize ($ value ) . ' ) ' );
94
94
}
95
95
96
96
/**
@@ -116,7 +116,7 @@ public function find($value)
116
116
*/
117
117
public function maybe ($ value )
118
118
{
119
- return $ this ->add (" (?: " . self ::sanitize ($ value ) . " )? " );
119
+ return $ this ->add (' (?: ' . self ::sanitize ($ value ) . ' )? ' );
120
120
}
121
121
122
122
/**
@@ -129,7 +129,7 @@ public function maybe($value)
129
129
*/
130
130
public function anything ()
131
131
{
132
- return $ this ->add (" (?:.*) " );
132
+ return $ this ->add (' (?:.*) ' );
133
133
}
134
134
135
135
/**
@@ -143,7 +143,7 @@ public function anything()
143
143
*/
144
144
public function anythingBut ($ value )
145
145
{
146
- return $ this ->add (" (?:[^ " . self ::sanitize ($ value ) . " ]*) " );
146
+ return $ this ->add (' (?:[^ ' . self ::sanitize ($ value ) . ' ]*) ' );
147
147
}
148
148
149
149
/**
@@ -156,7 +156,7 @@ public function anythingBut($value)
156
156
*/
157
157
public function something ()
158
158
{
159
- return $ this ->add (" (?:.+) " );
159
+ return $ this ->add (' (?:.+) ' );
160
160
}
161
161
162
162
/**
@@ -170,7 +170,7 @@ public function something()
170
170
*/
171
171
public function somethingBut ($ value )
172
172
{
173
- return $ this ->add (" (?:[^ " . self ::sanitize ($ value ) . " ]+) " );
173
+ return $ this ->add (' (?:[^ ' . self ::sanitize ($ value ) . ' ]+) ' );
174
174
}
175
175
176
176
/**
@@ -205,7 +205,7 @@ public function replace($source, $value)
205
205
*/
206
206
public function lineBreak ()
207
207
{
208
- return $ this ->add (" (?: \\n|( \\r \\n)) " );
208
+ return $ this ->add (' (?: \\n|( \\r \\n)) ' );
209
209
}
210
210
211
211
/**
@@ -231,7 +231,7 @@ public function br()
231
231
*/
232
232
public function tab ()
233
233
{
234
- return $ this ->add (" \\t " );
234
+ return $ this ->add (' \\t ' );
235
235
}
236
236
237
237
/**
@@ -244,7 +244,7 @@ public function tab()
244
244
*/
245
245
public function word ()
246
246
{
247
- return $ this ->add (" \\w+ " );
247
+ return $ this ->add (' \\w+ ' );
248
248
}
249
249
250
250
/**
@@ -258,7 +258,7 @@ public function word()
258
258
*/
259
259
public function anyOf ($ value )
260
260
{
261
- return $ this ->add (" [ " . $ value . " ] " );
261
+ return $ this ->add (' [ ' . $ value . ' ] ' );
262
262
}
263
263
264
264
/**
@@ -290,17 +290,17 @@ public function range()
290
290
$ arg_num = func_num_args ();
291
291
292
292
if ($ arg_num %2 != 0 ) {
293
- throw new \InvalidArgumentException (" Number of args must be even " , 1 );
293
+ throw new \InvalidArgumentException (' Number of args must be even ' , 1 );
294
294
}
295
295
296
- $ value = " [ " ;
296
+ $ value = ' [ ' ;
297
297
$ arg_list = func_get_args ();
298
298
299
299
for ($ i = 0 ; $ i < $ arg_num ;) {
300
- $ value .= self ::sanitize ($ arg_list [$ i ++]) . " - " . self ::sanitize ($ arg_list [$ i ++]);
300
+ $ value .= self ::sanitize ($ arg_list [$ i ++]) . ' - ' . self ::sanitize ($ arg_list [$ i ++]);
301
301
}
302
302
303
- $ value .= " ] " ;
303
+ $ value .= ' ] ' ;
304
304
305
305
return $ this ->add ($ value );
306
306
}
@@ -418,15 +418,15 @@ public function multiple($value)
418
418
*/
419
419
public function _or ($ value )
420
420
{
421
- if (strpos ($ this ->prefixes , " ( " ) === false ) {
422
- $ this ->prefixes .= " (?: " ;
421
+ if (strpos ($ this ->prefixes , ' ( ' ) === false ) {
422
+ $ this ->prefixes .= ' (?: ' ;
423
423
}
424
424
425
- if (strpos ($ this ->suffixes , " ) " ) === false ) {
426
- $ this ->suffixes .= " ) " ;
425
+ if (strpos ($ this ->suffixes , ' ) ' ) === false ) {
426
+ $ this ->suffixes .= ' ) ' ;
427
427
}
428
428
429
- $ this ->add (" )|(?: " );
429
+ $ this ->add (' )|(?: ' );
430
430
431
431
if ($ value ) {
432
432
$ this ->add ($ value );
@@ -458,7 +458,7 @@ public function __toString()
458
458
*/
459
459
public function getRegex ()
460
460
{
461
- return " / " . $ this ->prefixes . $ this ->source . $ this ->suffixes . " / " . $ this ->modifiers ;
461
+ return ' / ' . $ this ->prefixes . $ this ->source . $ this ->suffixes . ' / ' . $ this ->modifiers ;
462
462
}
463
463
464
464
/**
@@ -493,7 +493,16 @@ public function test($value)
493
493
*/
494
494
public function clean (array $ options = array ())
495
495
{
496
- $ options = array_merge (array ("prefixes " => "" , "source " =>"" , "suffixes " =>"" , "modifiers " =>"gm " , "replaceLimit " =>"1 " ), $ options );
496
+ $ options = array_merge (
497
+ array (
498
+ 'prefixes ' => '' ,
499
+ 'source ' => '' ,
500
+ 'suffixes ' => '' ,
501
+ 'modifiers ' => 'gm ' ,
502
+ 'replaceLimit ' => '1 '
503
+ ),
504
+ $ options
505
+ );
497
506
$ this ->prefixes = $ options ['prefixes ' ];
498
507
$ this ->source = $ options ['source ' ];
499
508
$ this ->suffixes = $ options ['suffixes ' ];
@@ -519,15 +528,15 @@ public function clean(array $options = array())
519
528
public function limit ($ min , $ max = 0 )
520
529
{
521
530
if ($ max == 0 ) {
522
- $ value = " { " . $ min . " } " ;
531
+ $ value = ' { ' . $ min . ' } ' ;
523
532
} elseif ($ max < $ min ) {
524
- $ value = " { " . $ min . " ,} " ;
533
+ $ value = ' { ' . $ min . ' ,} ' ;
525
534
} else {
526
- $ value = " { " . $ min . " , " . $ max . " } " ;
535
+ $ value = ' { ' . $ min . ' , ' . $ max . ' } ' ;
527
536
}
528
537
529
538
// check if the expression has * or + for the last expression
530
- if (preg_match (" /\*|\+/ " , $ this ->lastAdded )) {
539
+ if (preg_match (' /\*|\+/ ' , $ this ->lastAdded )) {
531
540
$ l = 1 ;
532
541
$ this ->source = strrev (str_replace (array ('+ ' ,'* ' ), strrev ($ value ), strrev ($ this ->source ), $ l ));
533
542
0 commit comments