File tree Expand file tree Collapse file tree 4 files changed +42
-7
lines changed Expand file tree Collapse file tree 4 files changed +42
-7
lines changed Original file line number Diff line number Diff line change @@ -33,13 +33,15 @@ public static function cleanString(string $stringToClean): string
33
33
'/[ÓÒÔÕÖ]/u ' => 'O ' ,
34
34
'/[úùûü]/u ' => 'u ' ,
35
35
'/[ÚÙÛÜ]/u ' => 'U ' ,
36
+ '/[ŶŸ]/u ' => 'Y ' ,
37
+ '/[ŷÿ]/u ' => 'y ' ,
36
38
'/ç/ ' => 'c ' ,
37
39
'/Ç/ ' => 'C ' ,
38
40
'/ñ/ ' => 'n ' ,
39
41
'/Ñ/ ' => 'N ' ,
40
42
'/–/ ' => '- ' , // UTF-8 hyphen to "normal" hyphen
41
- ' /[’‘‹›‚]/u ' => ' ' , // Literally a single quote
42
- '/[“”«»„]/u ' => ' ' , // Double quote
43
+ " /[’‘' ‹›‚]/u " => '' , // Literally a single quote
44
+ '/[" “”«»„]/u ' => '' , // Double quote
43
45
'/ / ' => ' ' , // non-breaking space (equiv. to 0x160)
44
46
];
45
47
Original file line number Diff line number Diff line change @@ -28,11 +28,13 @@ public static function isStringIsEquals(...$strings): bool
28
28
}
29
29
30
30
/**
31
+ * This will compare a text with specials char for example têxt will be equals to text
32
+ *
31
33
* @param ...$strings
32
34
*
33
35
* @return bool
34
36
*/
35
- public static function compareCleanString (...$ strings ): bool
37
+ public static function compareCleanedString (...$ strings ): bool
36
38
{
37
39
$ results = [];
38
40
foreach ($ strings as $ string ) {
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * @author <julienrajerison5@gmail.com>
4
+ */
5
+
6
+ use Julkwel \StringTools \StrCleaner ;
7
+ use PHPUnit \Framework \TestCase ;
8
+
9
+ /**
10
+ * String cleaner class testing
11
+ *
12
+ * Class StrCleanerTest.
13
+ */
14
+ class StrCleanerTest extends TestCase
15
+ {
16
+ /**
17
+ * Test cleaning a phrase
18
+ */
19
+ public function testCleaningAPhrase ()
20
+ {
21
+ $ textToClean = "ÉÉÊÊÎÎÎî ëŷ we are with spécïal charactêrs and w'ill clean " ;
22
+ $ toResults = "eeeeiiii ey we are with special characters and will clean " ;
23
+ $ this ->assertEquals ($ toResults , StrCleaner::cleanString ($ textToClean ));
24
+ }
25
+ }
Original file line number Diff line number Diff line change @@ -16,16 +16,22 @@ class StrCompareTest extends TestCase
16
16
*/
17
17
public function testFailingComparison ()
18
18
{
19
- $ strCompare = new StrCompare ();
20
- $ this ->assertFalse ($ strCompare ->isStringIsEquals ("z " , "x " ));
19
+ $ this ->assertFalse (StrCompare::isStringIsEquals ("z " , "x " ));
21
20
}
22
21
23
22
/**
24
23
* this test should succeed
25
24
*/
26
25
public function testSuccessComparison ()
27
26
{
28
- $ strCompare = new StrCompare ();
29
- $ this ->assertTrue ($ strCompare ->isStringIsEquals ("test " , "test " ));
27
+ $ this ->assertTrue (StrCompare::isStringIsEquals ("test " , "test " ));
28
+ }
29
+
30
+ /**
31
+ * testing special comparison
32
+ */
33
+ public function testWithSpecialChar ()
34
+ {
35
+ $ this ->assertTrue (StrCompare::compareCleanedString ("SPÊCÏAL CHAR'S " , "special chars " ));
30
36
}
31
37
}
You can’t perform that action at this time.
0 commit comments