Completed
Push — master ( 752265...56f7fa )
by Sworup
03:34
created
src/ProfanityFilter.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@
 block discarded – undo
17 17
 
18 18
     public function clean($string, $censorChar = "*")
19 19
     {
20
-        if (empty($string)) return $this->createOutputObject();
20
+        if (empty($string)) {
21
+            return $this->createOutputObject();
22
+        }
21 23
 
22 24
         $newstring = $this->checkForBadWordsAnywhere($string, $censorChar);
23 25
         $newstring = $this->checkForBlackListedWords($newstring, $censorChar);
Please login to merge, or discard this patch.
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -25,6 +25,9 @@  discard block
 block discarded – undo
25 25
         return $this->createOutputObject($string, $newstring);
26 26
     }
27 27
 
28
+    /**
29
+     * @param string $censorChar
30
+     */
28 31
     private function checkForBadWordsAnywhere($string, $censorChar)
29 32
     {
30 33
         $replace   = $this->replace;
@@ -43,6 +46,11 @@  discard block
 block discarded – undo
43 46
         return $returnString;
44 47
     }
45 48
 
49
+    /**
50
+     * @param string $censorChar
51
+     *
52
+     * @return string
53
+     */
46 54
     private function checkForBlackListedWords($string, $censorChar)
47 55
     {
48 56
         $blackList = $this->blackList;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
 
28 28
     private function checkForBadWordsAnywhere($string, $censorChar)
29 29
     {
30
-        $replace   = $this->replace;
30
+        $replace = $this->replace;
31 31
 
32 32
         $returnString = $string;
33
-        $badwordsInEveryLanguage  = $this->swearWords;
33
+        $badwordsInEveryLanguage = $this->swearWords;
34 34
 
35 35
         foreach ($badwordsInEveryLanguage as $badwords) {
36 36
             foreach ($badwords as $badword) {
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
         $replace   = $this->replace;
50 50
         $replacement = array();
51 51
         $total_blacklist = count($blackList);
52
-        for($i=0;$i < $total_blacklist;$i++) {
52
+        for ($i = 0; $i < $total_blacklist; $i++) {
53 53
             $splitword = str_split($blackList[$i]);
54 54
             $first_time_through = true;
55 55
             $regex_ready_word = "";
56 56
             $replacement[$i] = str_repeat($censorChar, strlen($blackList[$i]));
57
-            foreach($splitword as $letter) {
58
-                if($first_time_through) {
57
+            foreach ($splitword as $letter) {
58
+                if ($first_time_through) {
59 59
                     $first_time_through = false;
60 60
                     $regex_ready_word .= str_ireplace(array_keys($replace), array_values($replace), $letter);
61 61
                 } else {
62
-                    $regex_ready_word .= "\W*".str_ireplace(array_keys($replace), array_values($replace), $letter);
62
+                    $regex_ready_word .= "\W*" . str_ireplace(array_keys($replace), array_values($replace), $letter);
63 63
                 }
64 64
             }
65 65
 
66
-            $blackList[$i] ="#\b$regex_ready_word\b#i";
66
+            $blackList[$i] = "#\b$regex_ready_word\b#i";
67 67
         }
68 68
         return preg_replace($blackList, $replacement, $string);
69 69
     }
Please login to merge, or discard this patch.
src/ProfanityFilterServiceProvider.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
      */
25 25
     public function register()
26 26
     {
27
-        $this->app['profanity'] = $this->app->share(function ($app) {
27
+        $this->app['profanity'] = $this->app->share(function($app) {
28 28
             $dependency = $this->app['config']['profanity-filter.words'];
29 29
             $blacklist  = $this->app['config']['profanity-filter.blacklist'];
30 30
             $replace    = $this->app['config']['profanity-filter.replace'];
Please login to merge, or discard this patch.