Passed
Push — master ( 7a3879...fb1031 )
by MOHAMMAD
01:31
created
src/Converter/HTMLConverter.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 
64 64
     $this->text = preg_replace_callback('%<a[^>]+>(.+?)</a>%iu',
65 65
 
66
-      function ($matches) {
66
+      function($matches) {
67 67
 
68 68
         // Extracts the url.
69 69
         if (preg_match('/\s*href\s*=\s*("([^"]*")|\'[^\']*\'|([^\'">\s]+))/iu', $matches[0], $others) === 1) {
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
   protected function replaceImages() {
95 95
     $this->text = preg_replace_callback('/<img[^>]+>/iu',
96 96
 
97
-      function ($matches) {
97
+      function($matches) {
98 98
 
99 99
         // Extracts the src.
100 100
         if (preg_match('/\s*src\s*=\s*("([^"]*")|\'[^\']*\'|([^\'">\s]+))/iu', $matches[0], $others) === 1)
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
   protected function replaceOtherTags() {
119 119
     $this->text = preg_replace_callback('%</?[a-z][a-z0-9]*[^<>]*>%iu',
120 120
 
121
-      function ($matches) {
121
+      function($matches) {
122 122
         $tag = strtolower($matches[0]);
123 123
 
124 124
         switch ($tag) {
Please login to merge, or discard this patch.
Braces   +19 added lines, -16 removed lines patch added patch discarded remove patch
@@ -44,12 +44,13 @@  discard block
 block discarded – undo
44 44
 
45 45
     for ($i = 0; $i < $snippetsCount; $i++) {
46 46
       // We try to determine which tags the code is inside: <pre></pre>, <code></code>, [code][/code]
47
-      if (!empty($this->snippets['openpre'][$i]))
48
-        $snippet = "[code]".PHP_EOL.trim($this->snippets['contentpre'][$i]).PHP_EOL."[/code]";
49
-      elseif (!empty($this->snippets['opencode'][$i]))
50
-        $snippet = "[code]".PHP_EOL.trim($this->snippets['contentcode'][$i]).PHP_EOL."[/code]";
51
-      else
52
-        $snippet = $this->snippets['openbbcode'][$i].PHP_EOL.trim($this->snippets['contentbbcode'][$i]).PHP_EOL.$this->snippets['closebbcode'][$i];
47
+      if (!empty($this->snippets['openpre'][$i])) {
48
+              $snippet = "[code]".PHP_EOL.trim($this->snippets['contentpre'][$i]).PHP_EOL."[/code]";
49
+      } elseif (!empty($this->snippets['opencode'][$i])) {
50
+              $snippet = "[code]".PHP_EOL.trim($this->snippets['contentcode'][$i]).PHP_EOL."[/code]";
51
+      } else {
52
+              $snippet = $this->snippets['openbbcode'][$i].PHP_EOL.trim($this->snippets['contentbbcode'][$i]).PHP_EOL.$this->snippets['closebbcode'][$i];
53
+      }
53 54
 
54 55
       $this->text = preg_replace('/___SNIPPET___/', PHP_EOL.trim($snippet).PHP_EOL, $this->text, 1);
55 56
     }
@@ -70,13 +71,14 @@  discard block
 block discarded – undo
70 71
           $href = trim($others[1], '"');
71 72
 
72 73
           // Extracts the target.
73
-          if (preg_match('/\s*target\s*=\s*("([^"]*")|\'[^\']*\'|([^\'">\s]+))/iu', $matches[0], $others) === 1)
74
-            $target = strtolower(trim($others[1], '"'));
75
-          else
76
-            $target = "_self";
74
+          if (preg_match('/\s*target\s*=\s*("([^"]*")|\'[^\']*\'|([^\'">\s]+))/iu', $matches[0], $others) === 1) {
75
+                      $target = strtolower(trim($others[1], '"'));
76
+          } else {
77
+                      $target = "_self";
78
+          }
79
+        } else {
80
+                  throw new \RuntimeException(sprintf("Text identified by '%d' has malformed links", $this->id));
77 81
         }
78
-        else
79
-          throw new \RuntimeException(sprintf("Text identified by '%d' has malformed links", $this->id));
80 82
 
81 83
         return "[url=".$href." t=".$target."]".$matches[1]."[/url]";
82 84
 
@@ -97,10 +99,11 @@  discard block
 block discarded – undo
97 99
       function ($matches) {
98 100
 
99 101
         // Extracts the src.
100
-        if (preg_match('/\s*src\s*=\s*("([^"]*")|\'[^\']*\'|([^\'">\s]+))/iu', $matches[0], $others) === 1)
101
-          $src = trim($others[1], '"');
102
-        else
103
-          throw new \RuntimeException(sprintf("Text identified by '%d' has malformed images", $this->id));
102
+        if (preg_match('/\s*src\s*=\s*("([^"]*")|\'[^\']*\'|([^\'">\s]+))/iu', $matches[0], $others) === 1) {
103
+                  $src = trim($others[1], '"');
104
+        } else {
105
+                  throw new \RuntimeException(sprintf("Text identified by '%d' has malformed images", $this->id));
106
+        }
104 107
 
105 108
         return "[img]".$src."[/img]";
106 109
 
Please login to merge, or discard this patch.
src/Converter/BBCodeConverter.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
             $text = $this->text;
53 53
         }
54 54
 
55
-        if ( ! $text) {
55
+        if (!$text) {
56 56
             return $text;
57 57
         }
58 58
 
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
      */
78 78
     protected function removeColor()
79 79
     {
80
-        $this->cleaners['removeColor'] = function ($text) {
80
+        $this->cleaners['removeColor'] = function($text) {
81 81
             return preg_replace_callback('%\[color=\#?\w+\]([\W\D\w\s]*?)\[/color\]%iu',
82
-                function ($matches) {
82
+                function($matches) {
83 83
                     return $matches[1];
84 84
                 },
85 85
 
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
      */
94 94
     protected function replaceSize()
95 95
     {
96
-        $this->cleaners['replaceSize'] = function ($text) {
96
+        $this->cleaners['replaceSize'] = function($text) {
97 97
             return preg_replace_callback('%\[size=(\d*)\]([\W\D\w\s]*?)\[/size\]%iu',
98
-                function ($matches) {
98
+                function($matches) {
99 99
                     $size = min((int) $matches[1], 6);
100 100
 
101 101
                     $multiplier = -1 * $size + 7;
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
      */
114 114
     protected function removeCenter()
115 115
     {
116
-        $this->cleaners['removeCenter'] = function ($text) {
116
+        $this->cleaners['removeCenter'] = function($text) {
117 117
             return preg_replace_callback('%\[center\]([\W\D\w\s]*?)\[/center\]%iu',
118
-                function ($matches) {
118
+                function($matches) {
119 119
                     return $matches[1];
120 120
                 },
121 121
 
@@ -129,9 +129,9 @@  discard block
 block discarded – undo
129 129
      */
130 130
     protected function replaceBold()
131 131
     {
132
-        $this->cleaners['replaceBold'] = function ($text) {
132
+        $this->cleaners['replaceBold'] = function($text) {
133 133
             return preg_replace_callback('%\[b\]([\W\D\w\s]*?)\[/b\]%iu',
134
-                function ($matches) {
134
+                function($matches) {
135 135
                     return '**'.trim($matches[1], ' ').'**';
136 136
                 },
137 137
 
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
      */
146 146
     protected function replaceItalic()
147 147
     {
148
-        $this->cleaners['replaceItalic'] = function ($text) {
148
+        $this->cleaners['replaceItalic'] = function($text) {
149 149
             return preg_replace_callback('%\[i\]([\W\D\w\s]*?)\[/i\]%iu',
150
-                function ($matches) {
150
+                function($matches) {
151 151
                     return '*'.trim($matches[1], ' ').'*';
152 152
                 },
153 153
 
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
      */
162 162
     protected function replaceUnderline()
163 163
     {
164
-        $this->cleaners['replaceUnderline'] = function ($text) {
164
+        $this->cleaners['replaceUnderline'] = function($text) {
165 165
             return preg_replace_callback('%\[u\]([\W\D\w\s]*?)\[/u\]%iu',
166
-                function ($matches) {
166
+                function($matches) {
167 167
                     return '_'.trim($matches[1], ' ').'_';
168 168
                 },
169 169
 
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
      */
178 178
     protected function replaceStrikethrough()
179 179
     {
180
-        $this->cleaners['replaceStrikethrough'] = function ($text) {
180
+        $this->cleaners['replaceStrikethrough'] = function($text) {
181 181
             return preg_replace_callback('%\[s\]([\W\D\w\s]*?)\[/s\]%iu',
182
-                function ($matches) {
182
+                function($matches) {
183 183
                     return '~~'.trim($matches[1], ' ').'~~';
184 184
                 },
185 185
 
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
      */
194 194
     protected function replaceLists()
195 195
     {
196
-        $this->cleaners['replaceLists'] = function ($text, $id = null) {
196
+        $this->cleaners['replaceLists'] = function($text, $id = null) {
197 197
             return preg_replace_callback('%\[list(?P<type>=1)?\](?P<items>[\W\D\w\s]*?)\[/list\]%iu',
198
-                function ($matches) use ($id) {
198
+                function($matches) use ($id) {
199 199
                     $buffer = '';
200 200
 
201 201
                     $list = preg_replace('/\s*$|^\s*/mu', '', $matches['items']);
@@ -209,21 +209,21 @@  discard block
 block discarded – undo
209 209
                     if (isset($matches['type']) && '=1' == $matches['type']) { // ordered list
210 210
                         // We start from 1 to discard the first string, in fact, it's empty.
211 211
                         for ($i = 1; $i < $counter; ++$i) {
212
-                            if ( ! empty($items[$i])) {
212
+                            if (!empty($items[$i])) {
213 213
                                 $buffer .= (string) ($i).'. '.trim($items[$i]).PHP_EOL;
214 214
                             }
215 215
                         }
216 216
                     } else { // unordered list
217 217
                         // We start from 1 to discard the first string, in fact, it's empty.
218 218
                         for ($i = 1; $i < $counter; ++$i) {
219
-                            if ( ! empty($items[$i])) {
219
+                            if (!empty($items[$i])) {
220 220
                                 $buffer .= '- '.trim($items[$i]).PHP_EOL;
221 221
                             }
222 222
                         }
223 223
                     }
224 224
 
225 225
                     // We need a like break above the list and another one below.
226
-                    if ( ! empty($buffer)) {
226
+                    if (!empty($buffer)) {
227 227
                         $buffer = PHP_EOL.$buffer.PHP_EOL;
228 228
                     }
229 229
 
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
      */
241 241
     protected function replaceUrls()
242 242
     {
243
-        $this->cleaners['replaceUrls'] = function ($text, $id = null) {
243
+        $this->cleaners['replaceUrls'] = function($text, $id = null) {
244 244
             return preg_replace_callback('%\[url\s*=\s*(?:"([^"]*)"|\A[^\']*\Z|(?:[^\'">\]\s]+))\s*(?:[^]\s]*)\]([\W\D\w\s]*?)\[/url\]%iu',
245
-                function ($matches) use ($id) {
245
+                function($matches) use ($id) {
246 246
                     if (isset($matches[1]) && isset($matches[2])) {
247 247
                         return '['.$matches[2].']('.$matches[1].')';
248 248
                     }
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
      */
261 261
     protected function replaceImages()
262 262
     {
263
-        $this->cleaners['replaceImages'] = function ($text, $id = null) {
263
+        $this->cleaners['replaceImages'] = function($text, $id = null) {
264 264
             return preg_replace_callback('%\[img\s*\]\s*("(?:[^"]*")|\A[^\']*\Z|(?:[^\'">\]\s]+))\s*(?:[^]\s]*)\[/img\]%iu',
265
-                function ($matches) use ($id) {
265
+                function($matches) use ($id) {
266 266
                     if (isset($matches[1])) {
267 267
                         return PHP_EOL.'![]'.'('.$matches[1].')'.PHP_EOL;
268 268
                     }
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
      */
282 282
     protected function replaceQuotes()
283 283
     {
284
-        $this->cleaners['replaceQuotes'] = function ($text, $id = null) {
284
+        $this->cleaners['replaceQuotes'] = function($text, $id = null) {
285 285
             // Removes the inner quotes, leaving just one level.
286 286
             $text = preg_replace('~\G(?<!^)(?>(\[quote\b[^]]*](?>[^[]++|\[(?!/?quote)|(?1))*\[/quote])|(?<!\[)(?>[^[]++|\[(?!/?quote))+\K)|\[quote\b[^]]*]\K~i', '', $text);
287 287
 
288 288
             // Replaces all the remaining quotes with '> ' characters.
289 289
             $text = preg_replace_callback('%\[quote\b[^]]*\]((?>[^[]++|\[(?!/?quote))*)\[/quote\]%i',
290
-                function ($matches) {
290
+                function($matches) {
291 291
                     $quote = preg_replace('/^\s*/mu', '', trim($matches[1]));
292 292
 
293 293
                     return '> '.$quote.PHP_EOL.PHP_EOL;
@@ -305,9 +305,9 @@  discard block
 block discarded – undo
305 305
      */
306 306
     protected function replaceSnippets()
307 307
     {
308
-        $this->cleaners['replaceSnippets'] = function ($text, $id = null) {
308
+        $this->cleaners['replaceSnippets'] = function($text, $id = null) {
309 309
             return preg_replace_callback('%\[code\s*=?(?P<language>\w*)\](?P<snippet>[\W\D\w\s]*?)\[\/code\]%iu',
310
-                function ($matches) use ($id) {
310
+                function($matches) use ($id) {
311 311
                     if (isset($matches['snippet'])) {
312 312
                         $language = strtolower($matches['language']);
313 313
 
Please login to merge, or discard this patch.