Passed
Push — master ( e8c874...e40a60 )
by Domenico
03:39 queued 12s
created
src/XliffReplacer/SdlXliffSAXTranslationReplacer.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
 
20 20
             // get id
21 21
             // trim to first 100 characters because this is the limit on Matecat's DB
22
-            $this->currentTransUnitId = substr($attr[ 'id' ], 0, 100);
22
+            $this->currentTransUnitId = substr($attr['id'], 0, 100);
23 23
 
24 24
             // current 'translate' attribute of the current trans-unit
25
-            $this->currentTransUnitTranslate = isset($attr[ 'translate' ]) ? $attr[ 'translate' ] : 'yes';
25
+            $this->currentTransUnitTranslate = isset($attr['translate']) ? $attr['translate'] : 'yes';
26 26
         }
27 27
 
28 28
         // check if we are entering into a <target>
29 29
         if ('target' == $name) {
30
-            if($this->currentTransUnitTranslate === 'no'){
30
+            if ($this->currentTransUnitTranslate === 'no') {
31 31
                 $this->inTarget = false;
32 32
             } else {
33 33
                 $this->inTarget = true;
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
                 } elseif ('sdl:seg' == $name) {
65 65
 
66 66
                     // write the confidence level for this segment ( Translated, Draft, etc. )
67
-                    if (isset($this->segments[ 'matecat|' . $this->currentTransUnitId ]) && $_sdlStatus_confWritten == false) {
67
+                    if (isset($this->segments['matecat|' . $this->currentTransUnitId]) && $_sdlStatus_confWritten == false) {
68 68
 
69 69
                         // append definition attribute
70
-                        $tag .= $this->prepareTargetStatuses($this->lastTransUnit[ $this->markerPos ]);
70
+                        $tag .= $this->prepareTargetStatuses($this->lastTransUnit[$this->markerPos]);
71 71
 
72 72
                         //prepare for an eventual next cycle
73 73
                         $this->markerPos++;
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
             // is outside current buffer (in the latter case, it's in next buffer to be read by the while loop);
95 95
             // this check is necessary because we may have truncated a tag in half with current read,
96 96
             // and the other half may be encountered in the next buffer it will be passed
97
-            if (isset($this->currentBuffer[ $idx - $this->offset ])) {
97
+            if (isset($this->currentBuffer[$idx - $this->offset])) {
98 98
                 // if this tag entire lenght fitted in the buffer, the last char must be the last
99 99
                 // symbol before the '>'; if it's an empty tag, it is assumed that it's a '/'
100 100
                 $tmp_offset = $idx - $this->offset;
101
-                $lastChar   = $this->currentBuffer[ $idx - $this->offset ];
101
+                $lastChar   = $this->currentBuffer[$idx - $this->offset];
102 102
             } else {
103 103
                 //if it's out, simple use the last character of the chunk
104 104
                 $tmp_offset = $this->len - 1;
105
-                $lastChar   = $this->currentBuffer[ $this->len - 1 ];
105
+                $lastChar   = $this->currentBuffer[$this->len - 1];
106 106
             }
107 107
 
108 108
             // trim last space
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
                 } else {
137 137
                     //these are NOT source/seg-source/value empty tags, THERE IS A CONTENT, write it in buffer
138 138
                     $this->bufferIsActive = true;
139
-                    $this->CDATABuffer    .= $tag;
139
+                    $this->CDATABuffer .= $tag;
140 140
                 }
141 141
             } else {
142 142
                 $this->postProcAndFlush($this->outputFP, $tag);
@@ -156,11 +156,11 @@  discard block
 block discarded – undo
156 156
     {
157 157
         $endTags = "";
158 158
 
159
-        $segment     = Strings::removeDangerousChars($seg [ 'segment' ]);
160
-        $translation = Strings::removeDangerousChars($seg [ 'translation' ]);
159
+        $segment     = Strings::removeDangerousChars($seg ['segment']);
160
+        $translation = Strings::removeDangerousChars($seg ['translation']);
161 161
         $dataRefMap  = (isset($seg['data_ref_map']) && $seg['data_ref_map'] !== null) ? Strings::jsonToArray($seg['data_ref_map']) : [];
162 162
 
163
-        if (is_null($seg [ 'translation' ]) || $seg [ 'translation' ] == '') {
163
+        if (is_null($seg ['translation']) || $seg ['translation'] == '') {
164 164
             $translation = $segment;
165 165
         } else {
166 166
             if ($this->callback) {
@@ -173,20 +173,20 @@  discard block
 block discarded – undo
173 173
         // for Trados the trailing spaces after </mrk> are meaningful
174 174
         // so we trim the translation from Matecat DB and add them after </mrk>
175 175
         $trailingSpaces = '';
176
-        for ($s=0; $s < Strings::getTheNumberOfTrailingSpaces($translation); $s++){
176
+        for ($s = 0; $s < Strings::getTheNumberOfTrailingSpaces($translation); $s++) {
177 177
             $trailingSpaces .= ' ';
178 178
         }
179 179
 
180
-        if ($seg[ 'mrk_id' ] !== null && $seg[ 'mrk_id' ] != '') {
180
+        if ($seg['mrk_id'] !== null && $seg['mrk_id'] != '') {
181 181
             if ($this->targetLang === 'ja-JP') {
182
-                $seg[ 'mrk_succ_tags' ] = ltrim($seg[ 'mrk_succ_tags' ]);
182
+                $seg['mrk_succ_tags'] = ltrim($seg['mrk_succ_tags']);
183 183
             }
184 184
 
185
-            $translation = "<mrk mid=\"" . $seg[ 'mrk_id' ] . "\" mtype=\"seg\">" . $seg[ 'mrk_prev_tags' ] . rtrim($translation) . $seg[ 'mrk_succ_tags' ] . "</mrk>" . $trailingSpaces;
185
+            $translation = "<mrk mid=\"" . $seg['mrk_id'] . "\" mtype=\"seg\">" . $seg['mrk_prev_tags'] . rtrim($translation) . $seg['mrk_succ_tags'] . "</mrk>" . $trailingSpaces;
186 186
         }
187 187
 
188 188
         // we need to trim succ_tags here because we already added the trailing spaces after </mrk>
189
-        $transUnitTranslation .= $seg[ 'prev_tags' ] . $translation . $endTags . ltrim($seg[ 'succ_tags' ]);
189
+        $transUnitTranslation .= $seg['prev_tags'] . $translation . $endTags . ltrim($seg['succ_tags']);
190 190
 
191 191
         return $transUnitTranslation;
192 192
     }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             'REJECTED'   => 'RejectedTranslation',
207 207
         ];
208 208
 
209
-        return "conf=\"{$statusMap[ $segment[ 'status' ] ]}\" ";
209
+        return "conf=\"{$statusMap[$segment['status']]}\" ";
210 210
     }
211 211
 
212 212
     /**
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
      */
219 219
     protected function setTransUnitState($seg, $state_prop, $lastMrkState)
220 220
     {
221
-        return [ null, null ];
221
+        return [null, null];
222 222
     }
223 223
 
224 224
     /**
Please login to merge, or discard this patch.
src/Utils/Emoji.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7404,7 +7404,7 @@
 block discarded – undo
7404 7404
             '
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7402,7 +7402,7 @@
 block discarded – undo
7402 7402
             '
Please login to merge, or discard this patch.
src/XliffUtils/DataRefReplacer.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      *
18 18
      * @param array $map
19 19
      */
20
-    public function __construct( array $map)
20
+    public function __construct(array $map)
21 21
     {
22 22
         $this->map = $map;
23 23
     }
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
         $html = HtmlParser::parse($string);
49 49
 
50 50
         // 1. Replace <ph>|<sc>|<ec> tags
51
-        foreach ($html as $node){
51
+        foreach ($html as $node) {
52 52
             $string = $this->recursiveAddEquivTextToPhTag($node, $string);
53 53
         }
54 54
 
55 55
         // 2. Replace <pc> tags
56 56
         $toBeEscaped = Strings::isAnEscapedHTML($string);
57 57
 
58
-        if($this->stringContainsPcTags($string, $toBeEscaped)){
58
+        if ($this->stringContainsPcTags($string, $toBeEscaped)) {
59 59
 
60 60
             // replace self-closed <pc />
61 61
             $string = $this->replaceSelfClosedPcTags($string, $toBeEscaped);
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
             'dataRefEnd',
85 85
         ];
86 86
 
87
-        foreach ($dataRefTags as $tag){
88
-            preg_match('/ '.$tag.'=[\\\\"](.*?)[\\\\"]/', $string, $matches);
87
+        foreach ($dataRefTags as $tag) {
88
+            preg_match('/ ' . $tag . '=[\\\\"](.*?)[\\\\"]/', $string, $matches);
89 89
 
90
-            if(count($matches) > 0){
90
+            if (count($matches) > 0) {
91 91
                 return true;
92 92
             }
93 93
         }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
     {
103 103
         $html = HtmlParser::parse($string);
104 104
 
105
-        foreach ($html as $node){
105
+        foreach ($html as $node) {
106 106
             $string = $this->recursiveCleanFromEquivText($node, $string);
107 107
         }
108 108
 
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
      *
123 123
      * @return string
124 124
      */
125
-    private function recursiveAddEquivTextToPhTag( $node, $string)
125
+    private function recursiveAddEquivTextToPhTag($node, $string)
126 126
     {
127
-        if($node->has_children){
128
-            foreach ($node->inner_html as $childNode){
127
+        if ($node->has_children) {
128
+            foreach ($node->inner_html as $childNode) {
129 129
                 $string = $this->recursiveAddEquivTextToPhTag($childNode, $string);
130 130
             }
131 131
         } else {
@@ -134,18 +134,18 @@  discard block
 block discarded – undo
134 134
                     return $string;
135 135
                 }
136 136
 
137
-                $a = $node->node;  // complete match. Eg:  <ph id="source1" dataRef="source1"/>
138
-                $b = $node->attributes['dataRef'];   // map identifier. Eg: source1
137
+                $a = $node->node; // complete match. Eg:  <ph id="source1" dataRef="source1"/>
138
+                $b = $node->attributes['dataRef']; // map identifier. Eg: source1
139 139
 
140 140
 
141 141
                 // if isset a value in the map calculate base64 encoded value
142 142
                 // otherwise skip
143
-                if(!in_array($b, array_keys($this->map))){
143
+                if (!in_array($b, array_keys($this->map))) {
144 144
                     return $string;
145 145
                 }
146 146
 
147 147
                 // check if is null, in this case convert it to NULL string
148
-                if(is_null($this->map[$b])){
148
+                if (is_null($this->map[$b])) {
149 149
                     $this->map[$b] = 'NULL';
150 150
                 }
151 151
 
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
                 }
158 158
 
159 159
                 // if there is no id copy it from dataRef
160
-                $id = (!isset($node->attributes['id'])) ? ' id="'.$b.'" removeId="true"': '';
160
+                $id = (!isset($node->attributes['id'])) ? ' id="' . $b . '" removeId="true"' : '';
161 161
 
162 162
                 // introduce dataType for <ec>/<sc> tag handling
163
-                $dataType = ($this->isAEcOrScTag($node)) ? ' dataType="'.$node->tagname.'"' : '';
163
+                $dataType = ($this->isAEcOrScTag($node)) ? ' dataType="' . $node->tagname . '"' : '';
164 164
 
165 165
                 // replacement
166
-                $d = str_replace('/', $id.$dataType. ' equiv-text="base64:'.$base64EncodedValue.'"/', $a);
167
-                $a = str_replace(['<','>','&gt;', '&lt;'], '', $a);
168
-                $d = str_replace(['<','>','&gt;', '&lt;'], '', $d);
166
+                $d = str_replace('/', $id . $dataType . ' equiv-text="base64:' . $base64EncodedValue . '"/', $a);
167
+                $a = str_replace(['<', '>', '&gt;', '&lt;'], '', $a);
168
+                $d = str_replace(['<', '>', '&gt;', '&lt;'], '', $d);
169 169
 
170 170
                 // convert <ec>/<sc> into <ph>
171
-                if($this->isAEcOrScTag($node)){
172
-                    $d = 'ph'.substr($d, 2);
171
+                if ($this->isAEcOrScTag($node)) {
172
+                    $d = 'ph' . substr($d, 2);
173 173
                     $d = trim($d);
174 174
                 }
175 175
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         $regex = ($toBeEscaped) ? '/&lt;pc (.*?)&gt;/iu' : '/<pc (.*?)>/iu';
192 192
         preg_match_all($regex, $string, $openingPcMatches);
193 193
 
194
-        return (isset($openingPcMatches[0]) && count($openingPcMatches[0])>0);
194
+        return (isset($openingPcMatches[0]) && count($openingPcMatches[0]) > 0);
195 195
     }
196 196
 
197 197
     /**
@@ -202,27 +202,27 @@  discard block
 block discarded – undo
202 202
      */
203 203
     private function replaceSelfClosedPcTags($string, $toBeEscaped)
204 204
     {
205
-        if($toBeEscaped){
206
-            $string = str_replace(['&lt;','&gt;'],['<','>'],$string);
205
+        if ($toBeEscaped) {
206
+            $string = str_replace(['&lt;', '&gt;'], ['<', '>'], $string);
207 207
         }
208 208
 
209 209
         $regex = '/<pc[^>]+?\/>/iu';
210 210
         preg_match_all($regex, $string, $selfClosedPcMatches);
211 211
 
212
-        foreach ($selfClosedPcMatches[0] as $match){
212
+        foreach ($selfClosedPcMatches[0] as $match) {
213 213
 
214 214
             $html = HtmlParser::parse($match);
215 215
             $node = $html[0];
216 216
             $attributes = $node->attributes;
217 217
 
218
-            if(isset($attributes['dataRefStart']) && array_key_exists($node->attributes['dataRefStart'], $this->map)){
219
-                $replacement = '<ph id="'.$attributes['id'].'" dataType="pcSelf" originalData="'.base64_encode($match).'" dataRef="'.$attributes['dataRefStart'].'" equiv-text="base64:'.base64_encode($this->map[$node->attributes['dataRefStart']]).'"/>';
218
+            if (isset($attributes['dataRefStart']) && array_key_exists($node->attributes['dataRefStart'], $this->map)) {
219
+                $replacement = '<ph id="' . $attributes['id'] . '" dataType="pcSelf" originalData="' . base64_encode($match) . '" dataRef="' . $attributes['dataRefStart'] . '" equiv-text="base64:' . base64_encode($this->map[$node->attributes['dataRefStart']]) . '"/>';
220 220
                 $string = str_replace($match, $replacement, $string);
221 221
             }
222 222
         }
223 223
 
224
-        if($toBeEscaped){
225
-            $string = str_replace(['<','>'],['&lt;','&gt;'],$string);
224
+        if ($toBeEscaped) {
225
+            $string = str_replace(['<', '>'], ['&lt;', '&gt;'], $string);
226 226
         }
227 227
 
228 228
         return $string;
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
         $dataRefEndMap = [];
242 242
 
243 243
         foreach ($html as $index => $node) {
244
-            if ( $node->tagname === 'pc' ) {
244
+            if ($node->tagname === 'pc') {
245 245
                 $this->extractDataRefMapRecursively($node, $dataRefEndMap);
246 246
             }
247 247
         }
@@ -255,26 +255,26 @@  discard block
 block discarded – undo
255 255
      * @param object $node
256 256
      * @param $dataRefEndMap
257 257
      */
258
-    private function extractDataRefMapRecursively( $node, &$dataRefEndMap)
258
+    private function extractDataRefMapRecursively($node, &$dataRefEndMap)
259 259
     {
260
-        if($this->nodeContainsNestedPcTags($node)) {
261
-            foreach ( $node->inner_html as $nestedNode ) {
260
+        if ($this->nodeContainsNestedPcTags($node)) {
261
+            foreach ($node->inner_html as $nestedNode) {
262 262
                 $this->extractDataRefMapRecursively($nestedNode, $dataRefEndMap);
263 263
             }
264 264
         }
265 265
 
266 266
         // EXCLUDE self closed <pc/>
267
-        if($node->tagname === 'pc' && $node->self_closed === false){
268
-            if(isset($node->attributes['dataRefEnd'])){
267
+        if ($node->tagname === 'pc' && $node->self_closed === false) {
268
+            if (isset($node->attributes['dataRefEnd'])) {
269 269
                 $dataRefEnd = $node->attributes['dataRefEnd'];
270
-            } elseif(isset($node->attributes['dataRefStart'])) {
270
+            } elseif (isset($node->attributes['dataRefStart'])) {
271 271
                 $dataRefEnd = $node->attributes['dataRefStart'];
272 272
             } else {
273 273
                 $dataRefEnd = null;
274 274
             }
275 275
 
276 276
             $dataRefEndMap[] = [
277
-                    'id' => isset($node->attributes['id'] ) ? $node->attributes['id'] : null,
277
+                    'id' => isset($node->attributes['id']) ? $node->attributes['id'] : null,
278 278
                     'dataRefEnd' => $dataRefEnd,
279 279
             ];
280 280
         }
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
      */
289 289
     private function recursiveCleanFromEquivText($node, $string)
290 290
     {
291
-        if($node->has_children){
292
-            foreach ($node->inner_html as $childNode){
291
+        if ($node->has_children) {
292
+            foreach ($node->inner_html as $childNode) {
293 293
                 $string = $this->recursiveCleanFromEquivText($childNode, $string);
294 294
             }
295 295
         } else {
296
-            if(isset($node->attributes['dataRef']) && array_key_exists($node->attributes['dataRef'], $this->map)){
296
+            if (isset($node->attributes['dataRef']) && array_key_exists($node->attributes['dataRef'], $this->map)) {
297 297
                 $cleaned = preg_replace('/ equiv-text="(.*?)"/', '', $node->node);
298 298
                 $string = str_replace($node->node, $cleaned, $string);
299 299
             }
@@ -315,29 +315,29 @@  discard block
 block discarded – undo
315 315
         $regex = ($toBeEscaped) ? '/&lt;pc (.*?)&gt;/iu' : '/<pc (.*?)>/iu';
316 316
         preg_match_all($regex, $string, $openingPcMatches);
317 317
 
318
-        foreach ($openingPcMatches[0] as $index => $match){
318
+        foreach ($openingPcMatches[0] as $index => $match) {
319 319
             $attr = HtmlParser::getAttributes($openingPcMatches[1][$index]);
320 320
 
321 321
             // CASE 1 - Missing `dataRefStart`
322
-            if( isset($attr['dataRefEnd']) && !isset($attr['dataRefStart'])  ){
322
+            if (isset($attr['dataRefEnd']) && !isset($attr['dataRefStart'])) {
323 323
                 $attr['dataRefStart'] = $attr['dataRefEnd'];
324 324
             }
325 325
 
326 326
             // CASE 2 - Missing `dataRefEnd`
327
-            if( isset($attr['dataRefStart']) && !isset($attr['dataRefEnd'])  ){
327
+            if (isset($attr['dataRefStart']) && !isset($attr['dataRefEnd'])) {
328 328
                 $attr['dataRefEnd'] = $attr['dataRefStart'];
329 329
             }
330 330
 
331
-            if(isset($attr['dataRefStart'])){
331
+            if (isset($attr['dataRefStart'])) {
332 332
                 $startOriginalData = $match; // opening <pc>
333 333
                 $startValue = $this->map[$attr['dataRefStart']] ? $this->map[$attr['dataRefStart']] : 'NULL'; //handling null values in original data map
334 334
                 $base64EncodedStartValue = base64_encode($startValue);
335 335
                 $base64StartOriginalData = base64_encode($startOriginalData);
336 336
 
337 337
                 // conversion for opening <pc> tag
338
-                $openingPcConverted  = '<ph '. ((isset($attr['id'])) ? 'id="'.$attr['id'].'_1"' : '') .' dataType="pcStart" originalData="'.$base64StartOriginalData.'" dataRef="'
339
-                        .$attr['dataRefStart'].'" equiv-text="base64:'
340
-                        .$base64EncodedStartValue.'"/>';
338
+                $openingPcConverted = '<ph ' . ((isset($attr['id'])) ? 'id="' . $attr['id'] . '_1"' : '') . ' dataType="pcStart" originalData="' . $base64StartOriginalData . '" dataRef="'
339
+                        .$attr['dataRefStart'] . '" equiv-text="base64:'
340
+                        .$base64EncodedStartValue . '"/>';
341 341
 
342 342
                 $string = str_replace($startOriginalData, $openingPcConverted, $string);
343 343
             }
@@ -362,20 +362,20 @@  discard block
 block discarded – undo
362 362
         preg_match_all($regex, $string, $closingPcMatches, PREG_OFFSET_CAPTURE);
363 363
         $delta = 0;
364 364
 
365
-        foreach ( $closingPcMatches[ 0 ] as $index => $match ) {
365
+        foreach ($closingPcMatches[0] as $index => $match) {
366 366
             $offset = $match[1];
367 367
             $length = strlen($match[0]);
368 368
             $attr = $dataRefEndMap[$index];
369 369
 
370
-            if(!empty($attr) && isset($attr['dataRefEnd'])){
370
+            if (!empty($attr) && isset($attr['dataRefEnd'])) {
371 371
                 $endOriginalData = $match[0]; // </pc>
372 372
                 $endValue = $this->map[$attr['dataRefEnd']] ? $this->map[$attr['dataRefEnd']] : 'NULL';
373 373
                 $base64EncodedEndValue = base64_encode($endValue);
374 374
                 $base64EndOriginalData = base64_encode($endOriginalData);
375 375
 
376 376
                 // conversion for closing <pc> tag
377
-                $closingPcConverted = '<ph '. ((isset($attr['id'])) ? 'id="'.$attr['id'].'_2"': '') .' dataType="pcEnd" originalData="'.$base64EndOriginalData.'" dataRef="'
378
-                        .$attr['dataRefEnd'].'" equiv-text="base64:' .$base64EncodedEndValue.'"/>';
377
+                $closingPcConverted = '<ph ' . ((isset($attr['id'])) ? 'id="' . $attr['id'] . '_2"' : '') . ' dataType="pcEnd" originalData="' . $base64EndOriginalData . '" dataRef="'
378
+                        .$attr['dataRefEnd'] . '" equiv-text="base64:' . $base64EncodedEndValue . '"/>';
379 379
 
380 380
                 $realOffset = ($delta === 0) ? $offset : ($offset + $delta);
381 381
 
@@ -394,12 +394,12 @@  discard block
 block discarded – undo
394 394
      */
395 395
     private function nodeContainsNestedPcTags($node)
396 396
     {
397
-        if(!$node->has_children){
397
+        if (!$node->has_children) {
398 398
             return false;
399 399
         }
400 400
 
401 401
         foreach ($node->inner_html as $nestedNode) {
402
-            if($nestedNode->tagname === 'pc' && (isset($node->attributes['dataRefEnd']) || isset($node->attributes['dataRefStart']))){
402
+            if ($nestedNode->tagname === 'pc' && (isset($node->attributes['dataRefEnd']) || isset($node->attributes['dataRefStart']))) {
403 403
                 return true;
404 404
             }
405 405
         }
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
         $string = str_replace(' equiv-text=""', '', $string);
424 424
         $html = HtmlParser::parse($string);
425 425
 
426
-        foreach ($html as $node){
426
+        foreach ($html as $node) {
427 427
             $string = $this->recursiveRemoveOriginalData($node, $string);
428 428
         }
429 429
 
@@ -438,43 +438,43 @@  discard block
 block discarded – undo
438 438
      */
439 439
     private function recursiveRemoveOriginalData($node, $string)
440 440
     {
441
-        if($node->has_children){
442
-            foreach ($node->inner_html as $childNode){
441
+        if ($node->has_children) {
442
+            foreach ($node->inner_html as $childNode) {
443 443
                 $string = $this->recursiveRemoveOriginalData($childNode, $string);
444 444
             }
445 445
         } else {
446 446
 
447
-            if(!isset($node->attributes['dataRef'])){
447
+            if (!isset($node->attributes['dataRef'])) {
448 448
                 return $string;
449 449
             }
450 450
 
451
-            $a = $node->node;                  // complete match. Eg:  <ph id="source1" dataRef="source1"/>
451
+            $a = $node->node; // complete match. Eg:  <ph id="source1" dataRef="source1"/>
452 452
             $b = $node->attributes['dataRef']; // map identifier. Eg: source1
453
-            $c = $node->terminator;            // terminator: Eg: >
453
+            $c = $node->terminator; // terminator: Eg: >
454 454
 
455 455
             // if isset a value in the map calculate base64 encoded value
456 456
             // or it is an empty string
457 457
             // otherwise skip
458
-            if(!in_array($b, array_keys($this->map))  ){
458
+            if (!in_array($b, array_keys($this->map))) {
459 459
                 return $string;
460 460
             }
461 461
 
462 462
             // check if is null, in this case convert it to NULL string
463
-            if(is_null($this->map[$b])){
463
+            if (is_null($this->map[$b])) {
464 464
                 $this->map[$b] = 'NULL';
465 465
             }
466 466
 
467 467
             // remove id?
468
-            $removeId = (isset($node->attributes['removeId']) && $node->attributes['removeId'] === "true") ? ' id="'.$b.'" removeId="true"' : '';
468
+            $removeId = (isset($node->attributes['removeId']) && $node->attributes['removeId'] === "true") ? ' id="' . $b . '" removeId="true"' : '';
469 469
 
470 470
             // grab dataType attribute for <ec>/<sc> tag handling
471
-            $dataType = ($this->wasAEcOrScTag($node)) ? ' dataType="'.$node->attributes['dataType'].'"' : '';
471
+            $dataType = ($this->wasAEcOrScTag($node)) ? ' dataType="' . $node->attributes['dataType'] . '"' : '';
472 472
 
473
-            $d = str_replace($removeId.$dataType.' equiv-text="base64:'.base64_encode($this->map[$b]).'"/'.$c, '/'.$c, $a);
473
+            $d = str_replace($removeId . $dataType . ' equiv-text="base64:' . base64_encode($this->map[$b]) . '"/' . $c, '/' . $c, $a);
474 474
 
475 475
             // replace original <ec>/<sc> tag
476
-            if($this->wasAEcOrScTag($node)){
477
-                $d = $node->attributes['dataType'].substr($d, 3);
476
+            if ($this->wasAEcOrScTag($node)) {
477
+                $d = $node->attributes['dataType'] . substr($d, 3);
478 478
                 $d = trim($d);
479 479
             }
480 480
 
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
             $string = str_replace($a, $d, $string);
488 488
 
489 489
             // restoring <pc/> self-closed here
490
-            if(Strings::contains('dataType="pcSelf"', $d)){
490
+            if (Strings::contains('dataType="pcSelf"', $d)) {
491 491
                 preg_match('/\s?originalData="(.*?)"\s?/', $d, $originalDataMatches);
492 492
 
493 493
                 if (isset($originalDataMatches[1])) {
@@ -546,6 +546,6 @@  discard block
 block discarded – undo
546 546
      */
547 547
     private function wasAEcOrScTag($node)
548 548
     {
549
-        return (isset($node->attributes['dataType']) && ( $node->attributes['dataType'] === 'ec' || $node->attributes['dataType'] === 'sc'));
549
+        return (isset($node->attributes['dataType']) && ($node->attributes['dataType'] === 'ec' || $node->attributes['dataType'] === 'sc'));
550 550
     }
551 551
 }
Please login to merge, or discard this patch.