Skip to content

Commit b8c2577

Browse files
Idrinthmihai-vlc
authored andcommitted
making example and readme psr2 compliant (#27)
moving squizlabs/php_codesniffer to dev, there's no need in prod
1 parent ab2a488 commit b8c2577

File tree

3 files changed

+46
-54
lines changed

3 files changed

+46
-54
lines changed

Example.php

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,50 @@
1010
$regex = new \VerbalExpressions\PHPVerbalExpressions\VerbalExpressions();
1111

1212
$regex->startOfLine()
13-
->then("http")
14-
->maybe("s")
15-
->then("://")
16-
->maybe("www.")
17-
->anythingBut(" ")
18-
->endOfLine();
19-
20-
if($regex->test("http://github.com"))
21-
echo "valid url". '<br>';
22-
else
23-
echo "invalid url". '<br>';
13+
->then("http")
14+
->maybe("s")
15+
->then("://")
16+
->maybe("www.")
17+
->anythingBut(" ")
18+
->endOfLine();
19+
20+
if ($regex->test("http://github.com")) {
21+
echo "valid url". '<br>';
22+
} else {
23+
echo "invalid url". '<br>';
24+
}
2425

2526
if (preg_match($regex, 'http://github.com')) {
26-
echo 'valid url';
27+
echo 'valid url';
2728
} else {
28-
echo 'invalud url';
29+
echo 'invalid url';
2930
}
3031

3132
echo "<pre>". $regex->getRegex() ."</pre>";
3233

3334
echo $regex->clean(array("modifiers" => "m", "replaceLimit" => 4))
34-
->find(' ')
35-
->replace("This is a small test http://somesite.com and some more text.", "-");
35+
->find(' ')
36+
->replace("This is a small test http://somesite.com and some more text.", "-");
3637

3738

3839
echo "<hr>";
3940

4041
// limit
4142
echo $regex ->clean(array("modifiers" => "m"))
42-
->startOfLine()
43-
->anyOf("abc")
44-
->anythingBut(" ")
45-
->limit(1)
46-
->withAnyCase()
47-
->replace("Abracadabra is a nice word", "Ba");
43+
->startOfLine()
44+
->anyOf("abc")
45+
->anythingBut(" ")
46+
->limit(1)
47+
->withAnyCase()
48+
->replace("Abracadabra is a nice word", "Ba");
4849

4950
echo "<br>";
5051

5152

5253

5354
echo $regex ->clean(array("modifiers" => "gm"))
54-
->add("\b")
55-
->word()
56-
->limit(2, 3)
57-
->add("\b")
58-
->replace("test abc ab abcd", "*");
59-
60-
61-
62-
63-
64-
65-
66-
55+
->add("\b")
56+
->word()
57+
->limit(2, 3)
58+
->add("\b")
59+
->replace("test abc ab abcd", "*");

README.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,22 @@ VerbalExpressions is a PHP library that helps to construct hard regular expressi
1010

1111
// some tests
1212

13-
$regex = new VerbalExpressions;
13+
$regex = new VerbalExpressions();
1414

15-
$regex ->startOfLine()
16-
->then("http")
17-
->maybe("s")
18-
->then("://")
19-
->maybe("www.")
20-
->anythingBut(" ")
21-
->endOfLine();
15+
$regex->startOfLine()
16+
->then("http")
17+
->maybe("s")
18+
->then("://")
19+
->maybe("www.")
20+
->anythingBut(" ")
21+
->endOfLine();
2222

2323

24-
if($regex->test("https://github.com/"))
25-
echo "valid url";
26-
else
27-
echo "invalid url";
24+
if ($regex->test("http://github.com")) {
25+
echo "valid url". '<br>';
26+
} else {
27+
echo "invalid url". '<br>';
28+
}
2829

2930
if (preg_match($regex, 'http://github.com')) {
3031
echo 'valid url';
@@ -35,11 +36,9 @@ if (preg_match($regex, 'http://github.com')) {
3536

3637
echo "<pre>". $regex->getRegex() ."</pre>";
3738

38-
39-
40-
echo $regex ->clean(array("modifiers" => "m", "replaceLimit" => 4))
41-
->find(' ')
42-
->replace("This is a small test http://somesite.com and some more text.", "-");
39+
echo $regex->clean(array("modifiers" => "m", "replaceLimit" => 4))
40+
->find(' ')
41+
->replace("This is a small test http://somesite.com and some more text.", "-");
4342

4443
```
4544

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"type": "project",
55
"description": "PHP Regular expressions made easy",
66
"require": {
7-
"php": ">=5.6",
8-
"squizlabs/php_codesniffer": "^3.1"
7+
"php": ">=5.6"
98
},
109
"require-dev": {
11-
"phpunit/phpunit": "* >=4"
10+
"phpunit/phpunit": "* >=4",
11+
"squizlabs/php_codesniffer": "^3.1"
1212
},
1313
"minimum-stability": "stable",
1414
"autoload": {

0 commit comments

Comments
 (0)