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
3333 '/[ÓÒÔÕÖ]/u ' => 'O ' ,
3434 '/[úùûü]/u ' => 'u ' ,
3535 '/[ÚÙÛÜ]/u ' => 'U ' ,
36+ '/[ŶŸ]/u ' => 'Y ' ,
37+ '/[ŷÿ]/u ' => 'y ' ,
3638 '/ç/ ' => 'c ' ,
3739 '/Ç/ ' => 'C ' ,
3840 '/ñ/ ' => 'n ' ,
3941 '/Ñ/ ' => 'N ' ,
4042 '/–/ ' => '- ' , // 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
4345 '/ / ' => ' ' , // non-breaking space (equiv. to 0x160)
4446 ];
4547
Original file line number Diff line number Diff line change @@ -28,11 +28,13 @@ public static function isStringIsEquals(...$strings): bool
2828 }
2929
3030 /**
31+ * This will compare a text with specials char for example têxt will be equals to text
32+ *
3133 * @param ...$strings
3234 *
3335 * @return bool
3436 */
35- public static function compareCleanString (...$ strings ): bool
37+ public static function compareCleanedString (...$ strings ): bool
3638 {
3739 $ results = [];
3840 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
1616 */
1717 public function testFailingComparison ()
1818 {
19- $ strCompare = new StrCompare ();
20- $ this ->assertFalse ($ strCompare ->isStringIsEquals ("z " , "x " ));
19+ $ this ->assertFalse (StrCompare::isStringIsEquals ("z " , "x " ));
2120 }
2221
2322 /**
2423 * this test should succeed
2524 */
2625 public function testSuccessComparison ()
2726 {
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 " ));
3036 }
3137}
You can’t perform that action at this time.
0 commit comments