Passed
Push — master ( e8c874...e40a60 )
by Domenico
03:39 queued 12s
created
src/XliffParser.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -65,22 +65,22 @@  discard block
 block discarded – undo
65 65
      * @throws Exception\NotValidFileException
66 66
      * @throws Exception\XmlParsingException
67 67
      */
68
-    public function xliffToArray( $xliffContent, $collapseEmptyTags = false)
68
+    public function xliffToArray($xliffContent, $collapseEmptyTags = false)
69 69
     {
70 70
         $xliff = [];
71 71
         $xliffContent = self::forceUft8Encoding($xliffContent, $xliff);
72 72
         $xliffVersion = XliffVersionDetector::detect($xliffContent);
73 73
         $info = XliffProprietaryDetect::getInfoFromXliffContent($xliffContent);
74 74
 
75
-        if($xliffVersion === 1){
75
+        if ($xliffVersion === 1) {
76 76
             $xliffContent = self::removeInternalFileTagFromContent($xliffContent, $xliff);
77 77
         }
78 78
 
79
-        if($xliffVersion === 2){
79
+        if ($xliffVersion === 2) {
80 80
             $xliffContent = self::escapeDataInOriginalMap($xliffContent);
81 81
         }
82 82
 
83
-        if($collapseEmptyTags === false){
83
+        if ($collapseEmptyTags === false) {
84 84
             $xliffContent = self::insertPlaceholderInEmptyTags($xliffContent);
85 85
         }
86 86
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
         $enc = mb_detect_encoding($xliffContent);
106 106
 
107 107
         if ($enc !== 'UTF-8') {
108
-            $xliff[ 'parser-warnings' ][] = "Input identified as $enc ans converted UTF-8. May not be a problem if the content is English only";
108
+            $xliff['parser-warnings'][] = "Input identified as $enc ans converted UTF-8. May not be a problem if the content is English only";
109 109
 
110 110
             return iconv($enc, 'UTF-8', $xliffContent);
111 111
         }
@@ -126,22 +126,22 @@  discard block
 block discarded – undo
126 126
     private static function removeInternalFileTagFromContent($xliffContent, &$xliff)
127 127
     {
128 128
         $index = 1;
129
-        $a = Strings::preg_split( '|<internal-file[\s>]|si', $xliffContent );
129
+        $a = Strings::preg_split('|<internal-file[\s>]|si', $xliffContent);
130 130
 
131 131
         // no match, return original string
132
-        if(count($a) === 1){
132
+        if (count($a) === 1) {
133 133
             return $a[0];
134 134
         }
135 135
 
136
-        $b = Strings::preg_split( '|</internal-file>|si', $a[1] );
137
-        $strippedContent = $a[0].$b[1];
138
-        $xliff['files'][$index][ 'reference' ][] = self::extractBase64($b[0]);
136
+        $b = Strings::preg_split('|</internal-file>|si', $a[1]);
137
+        $strippedContent = $a[0] . $b[1];
138
+        $xliff['files'][$index]['reference'][] = self::extractBase64($b[0]);
139 139
         $index++;
140 140
 
141
-        if(isset($a[2])){
142
-            $c = Strings::preg_split( '|</internal-file[\s>]|si', $a[2] );
141
+        if (isset($a[2])) {
142
+            $c = Strings::preg_split('|</internal-file[\s>]|si', $a[2]);
143 143
             $strippedContent .= $c[1];
144
-            $xliff['files'][$index][ 'reference' ][] = self::extractBase64($c[0]);
144
+            $xliff['files'][$index]['reference'][] = self::extractBase64($c[0]);
145 145
         }
146 146
 
147 147
         return $strippedContent;
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
      */
179 179
     private static function escapeDataInOriginalMap($xliffContent)
180 180
     {
181
-        $xliffContent  = preg_replace_callback('/<data(.*?)>(.*?)<\/data>/iU', [XliffParser::class, 'replaceSpace' ], $xliffContent);
182
-        $xliffContent  = preg_replace_callback('/<data(.*?)>(.*?)<\/data>/iU', [XliffParser::class, 'replaceXliffTags' ], $xliffContent);
181
+        $xliffContent  = preg_replace_callback('/<data(.*?)>(.*?)<\/data>/iU', [XliffParser::class, 'replaceSpace'], $xliffContent);
182
+        $xliffContent  = preg_replace_callback('/<data(.*?)>(.*?)<\/data>/iU', [XliffParser::class, 'replaceXliffTags'], $xliffContent);
183 183
 
184 184
         return $xliffContent;
185 185
     }
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
     {
203 203
         preg_match_all('/<([a-zA-Z0-9._-]+)[^>]*><\/\1>/sm', $xliffContent, $emptyTagMatches);
204 204
 
205
-        if(!empty($emptyTagMatches[0])){
206
-            foreach ($emptyTagMatches[0] as $index => $emptyTagMatch){
205
+        if (!empty($emptyTagMatches[0])) {
206
+            foreach ($emptyTagMatches[0] as $index => $emptyTagMatch) {
207 207
                 $matchedTag = $emptyTagMatches[1][$index];
208
-                $subst = Placeholder::EMPTY_TAG_PLACEHOLDER.'</'.$matchedTag.'>';
209
-                $replacedTag = str_replace('</'.$matchedTag.'>', $subst, $emptyTagMatch);
208
+                $subst = Placeholder::EMPTY_TAG_PLACEHOLDER . '</' . $matchedTag . '>';
209
+                $replacedTag = str_replace('</' . $matchedTag . '>', $subst, $emptyTagMatch);
210 210
                 $xliffContent = str_replace($emptyTagMatch, $replacedTag, $xliffContent);
211 211
             }
212 212
         }
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         $content = str_replace('\n', Placeholder::NEW_LINE_PLACEHOLDER, $content);
228 228
         $content = str_replace('\t', Placeholder::TAB_PLACEHOLDER, $content);
229 229
 
230
-        return '<data'.$matches[1].'>'.$content.'</data>';
230
+        return '<data' . $matches[1] . '>' . $content . '</data>';
231 231
     }
232 232
 
233 233
     /**
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
         $xliffTags = XliffTags::$tags;
241 241
         $content = $matches[2];
242 242
 
243
-        foreach ($xliffTags as $xliffTag){
244
-            $content = preg_replace( '|&lt;('.$xliffTag.'.*?)&gt;|si', Placeholder::LT_PLACEHOLDER . "$1" . Placeholder::GT_PLACEHOLDER, $content );
245
-            $content = preg_replace( '|&lt;(/'.$xliffTag.')&gt;|si', Placeholder::LT_PLACEHOLDER . "$1" . Placeholder::GT_PLACEHOLDER, $content );
243
+        foreach ($xliffTags as $xliffTag) {
244
+            $content = preg_replace('|&lt;(' . $xliffTag . '.*?)&gt;|si', Placeholder::LT_PLACEHOLDER . "$1" . Placeholder::GT_PLACEHOLDER, $content);
245
+            $content = preg_replace('|&lt;(/' . $xliffTag . ')&gt;|si', Placeholder::LT_PLACEHOLDER . "$1" . Placeholder::GT_PLACEHOLDER, $content);
246 246
         }
247 247
 
248
-        return '<data'.$matches[1].'>'.$content.'</data>';
248
+        return '<data' . $matches[1] . '>' . $content . '</data>';
249 249
     }
250 250
 }
Please login to merge, or discard this patch.
src/XliffUtils/XliffProprietaryDetect.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      *
48 48
      * @return array
49 49
      */
50
-    private static function getInfoFromTmp( $tmp)
50
+    private static function getInfoFromTmp($tmp)
51 51
     {
52 52
         try {
53 53
             self::checkVersion($tmp);
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
         // run CheckXliffProprietaryPipeline
60 60
         $pipeline = self::runPipeline($tmp);
61 61
 
62
-        self::$fileType['proprietary' ] = $pipeline['proprietary' ];
63
-        self::$fileType[ 'proprietary_name' ] = $pipeline['proprietary_name' ];
64
-        self::$fileType[ 'proprietary_short_name' ] = $pipeline['proprietary_short_name' ];
65
-        self::$fileType[ 'converter_version' ] = $pipeline['converter_version' ];
62
+        self::$fileType['proprietary'] = $pipeline['proprietary'];
63
+        self::$fileType['proprietary_name'] = $pipeline['proprietary_name'];
64
+        self::$fileType['proprietary_short_name'] = $pipeline['proprietary_short_name'];
65
+        self::$fileType['converter_version'] = $pipeline['converter_version'];
66 66
 
67 67
         return self::$fileType;
68 68
     }
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         }
126 126
 
127 127
         if (!empty($stringData)) {
128
-            return array( $stringData );
128
+            return array($stringData);
129 129
         }
130 130
 
131 131
         return false;
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
      */
140 140
     protected static function checkVersion($tmp)
141 141
     {
142
-        if (isset($tmp[ 0 ])) {
143
-            self::$fileType[ 'version' ] = XliffVersionDetector::detect($tmp[ 0 ]);
142
+        if (isset($tmp[0])) {
143
+            self::$fileType['version'] = XliffVersionDetector::detect($tmp[0]);
144 144
         }
145 145
     }
146 146
 
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
         // run CheckXliffProprietaryPipeline
163 163
         $pipeline = self::runPipeline($tmp);
164 164
 
165
-        self::$fileType['proprietary' ] = $pipeline['proprietary' ];
166
-        self::$fileType[ 'proprietary_name' ] = $pipeline['proprietary_name' ];
167
-        self::$fileType[ 'proprietary_short_name' ] = $pipeline['proprietary_short_name' ];
168
-        self::$fileType[ 'converter_version' ] = $pipeline['converter_version' ];
165
+        self::$fileType['proprietary'] = $pipeline['proprietary'];
166
+        self::$fileType['proprietary_name'] = $pipeline['proprietary_name'];
167
+        self::$fileType['proprietary_short_name'] = $pipeline['proprietary_short_name'];
168
+        self::$fileType['converter_version'] = $pipeline['converter_version'];
169 169
 
170 170
         return self::$fileType;
171 171
     }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
                     //if file is not proprietary AND Enforce is disabled
196 196
                     //we take it as is
197
-                    if (!$fileType[ 'proprietary' ] or $memoryFileType) {
197
+                    if (!$fileType['proprietary'] or $memoryFileType) {
198 198
                         $convert = false;
199 199
                         //ok don't convert a standard sdlxliff
200 200
                     }
@@ -202,16 +202,16 @@  discard block
 block discarded – undo
202 202
                     //if conversion enforce is active
203 203
                     //we force all xliff files but not files produced by SDL Studio because we can handle them
204 204
                     if (
205
-                            $fileType[ 'proprietary_short_name' ] == 'matecat_converter'
206
-                            or $fileType[ 'proprietary_short_name' ] == 'trados'
207
-                            or $fileType[ 'proprietary_short_name' ] == 'xliff_v2'
205
+                            $fileType['proprietary_short_name'] == 'matecat_converter'
206
+                            or $fileType['proprietary_short_name'] == 'trados'
207
+                            or $fileType['proprietary_short_name'] == 'xliff_v2'
208 208
                             or $memoryFileType
209 209
                     ) {
210 210
                         $convert = false;
211 211
                         //ok don't convert a standard sdlxliff
212 212
                     }
213 213
                 }
214
-            } elseif ($fileType[ 'proprietary' ]) {
214
+            } elseif ($fileType['proprietary']) {
215 215
 
216 216
                 /**
217 217
                  * Application misconfiguration.
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 
222 222
                 $convert = -1;
223 223
             //stop execution
224
-            } elseif (!$fileType[ 'proprietary' ]) {
224
+            } elseif (!$fileType['proprietary']) {
225 225
                 $convert = false;
226 226
                 //ok don't convert a standard sdlxliff
227 227
             }
Please login to merge, or discard this patch.
src/XliffUtils/XliffVersionDetector.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
     {
29 29
         preg_match('|<xliff.*?\sversion\s?=\s?["\'](.*?)["\']|si', substr($xliffContent, 0, 1000), $versionMatches);
30 30
 
31
-        if (empty($versionMatches) ) {
31
+        if (empty($versionMatches)) {
32 32
             throw new NotValidFileException('This is not a valid xliff file');
33 33
         }
34 34
 
Please login to merge, or discard this patch.
src/XliffUtils/CheckPipeline/CheckXliffVersion2.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
     {
14 14
         $fileType = [];
15 15
 
16
-        if (isset($tmp[ 0 ])) {
16
+        if (isset($tmp[0])) {
17 17
             preg_match('|<xliff.*?\sversion\s?=\s?["\'](.*?)["\']|si', substr($tmp[0], 0, 1000), $versionMatches);
18 18
             preg_match('|<xliff.*?\sxmlns\s?=\s?["\']urn:oasis:names:tc:xliff:document:(.*?)["\']|si', substr($tmp[0], 0, 1000), $xmlnsMatches);
19 19
 
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
                 $xmlns = $xmlnsMatches[1];
23 23
 
24 24
                 if ($version === $xmlns and $version >= 2) {
25
-                    $fileType[ 'proprietary' ]            = false;
26
-                    $fileType[ 'proprietary_name' ]       = 'Xliff v'.$version.' File';
27
-                    $fileType[ 'proprietary_short_name' ] = 'xliff_v2';
28
-                    $fileType[ 'converter_version' ]      = '2.0';
25
+                    $fileType['proprietary']            = false;
26
+                    $fileType['proprietary_name']       = 'Xliff v' . $version . ' File';
27
+                    $fileType['proprietary_short_name'] = 'xliff_v2';
28
+                    $fileType['converter_version']      = '2.0';
29 29
 
30 30
                     return $fileType;
31 31
                 }
Please login to merge, or discard this patch.
src/XliffUtils/CheckPipeline/CheckGlobalSight.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,12 +13,12 @@
 block discarded – undo
13 13
     {
14 14
         $fileType = [];
15 15
 
16
-        if (isset($tmp[ 0 ])) {
17
-            if (stripos($tmp[ 0 ], 'globalsight') !== false) {
18
-                $fileType[ 'proprietary' ]            = true;
19
-                $fileType[ 'proprietary_name' ]       = 'GlobalSight Download File';
20
-                $fileType[ 'proprietary_short_name' ] = 'globalsight';
21
-                $fileType[ 'converter_version' ]      = 'legacy';
16
+        if (isset($tmp[0])) {
17
+            if (stripos($tmp[0], 'globalsight') !== false) {
18
+                $fileType['proprietary']            = true;
19
+                $fileType['proprietary_name']       = 'GlobalSight Download File';
20
+                $fileType['proprietary_short_name'] = 'globalsight';
21
+                $fileType['converter_version']      = 'legacy';
22 22
 
23 23
                 return $fileType;
24 24
             }
Please login to merge, or discard this patch.
src/XliffUtils/CheckPipeline/CheckMateCATConverter.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,17 +13,17 @@
 block discarded – undo
13 13
     {
14 14
         $fileType = [];
15 15
 
16
-        if (isset($tmp[ 0 ])) {
17
-            preg_match('#tool-id\s*=\s*"matecat-converter(\s+([^"]+))?"#i', $tmp[ 0 ], $matches);
16
+        if (isset($tmp[0])) {
17
+            preg_match('#tool-id\s*=\s*"matecat-converter(\s+([^"]+))?"#i', $tmp[0], $matches);
18 18
             if (!empty($matches)) {
19
-                $fileType[ 'proprietary' ]            = false;
20
-                $fileType[ 'proprietary_name' ]       = 'MateCAT Converter';
21
-                $fileType[ 'proprietary_short_name' ] = 'matecat_converter';
22
-                if (isset($matches[ 2 ])) {
23
-                    $fileType[ 'converter_version' ] = $matches[ 2 ];
19
+                $fileType['proprietary']            = false;
20
+                $fileType['proprietary_name']       = 'MateCAT Converter';
21
+                $fileType['proprietary_short_name'] = 'matecat_converter';
22
+                if (isset($matches[2])) {
23
+                    $fileType['converter_version'] = $matches[2];
24 24
                 } else {
25 25
                     // First converter release didn't specify version
26
-                    $fileType[ 'converter_version' ] = '1.0';
26
+                    $fileType['converter_version'] = '1.0';
27 27
                 }
28 28
 
29 29
                 return $fileType;
Please login to merge, or discard this patch.
src/XliffUtils/CheckPipeline/CheckSDL.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,13 +8,13 @@
 block discarded – undo
8 8
     {
9 9
         $fileType = [];
10 10
 
11
-        if (isset($tmp[ 0 ])) {
12
-            if (stripos($tmp[ 0 ], 'sdl:version') !== false) {
11
+        if (isset($tmp[0])) {
12
+            if (stripos($tmp[0], 'sdl:version') !== false) {
13 13
                 //little trick, we consider not proprietary Sdlxliff files because we can handle them
14
-                $fileType[ 'proprietary' ]            = false;
15
-                $fileType[ 'proprietary_name' ]       = 'SDL Studio ';
16
-                $fileType[ 'proprietary_short_name' ] = 'trados';
17
-                $fileType[ 'converter_version' ]      = 'legacy';
14
+                $fileType['proprietary']            = false;
15
+                $fileType['proprietary_name']       = 'SDL Studio ';
16
+                $fileType['proprietary_short_name'] = 'trados';
17
+                $fileType['converter_version']      = 'legacy';
18 18
 
19 19
                 return $fileType;
20 20
             }
Please login to merge, or discard this patch.
src/XliffUtils/XmlParser.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,8 +65,8 @@
 block discarded – undo
65 65
                 } catch (\Exception $e) {
66 66
                     $valid = false;
67 67
                 }
68
-            } elseif (!is_array($schemaOrCallable) && is_file((string) $schemaOrCallable)) {
69
-                $schemaSource = file_get_contents((string) $schemaOrCallable);
68
+            } elseif (!is_array($schemaOrCallable) && is_file((string)$schemaOrCallable)) {
69
+                $schemaSource = file_get_contents((string)$schemaOrCallable);
70 70
                 $valid = @$dom->schemaValidateSource($schemaSource);
71 71
             } else {
72 72
                 libxml_use_internal_errors($internalErrors);
Please login to merge, or discard this patch.
src/XliffParser/XliffParserV2.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -17,17 +17,17 @@  discard block
 block discarded – undo
17 17
      * @inheritDoc
18 18
      * @throws \Exception
19 19
      */
20
-    public function parse( DOMDocument $dom, $output = [])
20
+    public function parse(DOMDocument $dom, $output = [])
21 21
     {
22 22
         $i = 1;
23 23
         /** @var DOMElement $file */
24 24
         foreach ($dom->getElementsByTagName('file') as $file) {
25 25
 
26 26
             // metadata
27
-            $output[ 'files' ][ $i ][ 'attr' ] = $this->extractMetadata($dom);
27
+            $output['files'][$i]['attr'] = $this->extractMetadata($dom);
28 28
 
29 29
             // notes
30
-            $output[ 'files' ][ $i ]['notes'] = $this->extractNotes($file);
30
+            $output['files'][$i]['notes'] = $this->extractNotes($file);
31 31
 
32 32
             // trans-units
33 33
             $transUnitIdArrayForUniquenessCheck = [];
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
      *
56 56
      * @return array
57 57
      */
58
-    private function extractMetadata( DOMDocument $dom)
58
+    private function extractMetadata(DOMDocument $dom)
59 59
     {
60 60
         $metadata = [];
61 61
 
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
         $fileNode = $dom->getElementsByTagName('file')->item(0);
64 64
 
65 65
         // original
66
-        $metadata[ 'original' ] = (null !== $fileNode->attributes->getNamedItem('original')) ? $fileNode->attributes->getNamedItem('original')->nodeValue : 'no-name';
66
+        $metadata['original'] = (null !== $fileNode->attributes->getNamedItem('original')) ? $fileNode->attributes->getNamedItem('original')->nodeValue : 'no-name';
67 67
 
68 68
         // source-language
69
-        $metadata[ 'source-language' ] = (null !== $xliffNode->attributes->getNamedItem('srcLang')) ? $xliffNode->attributes->getNamedItem('srcLang')->nodeValue : 'en-US';
69
+        $metadata['source-language'] = (null !== $xliffNode->attributes->getNamedItem('srcLang')) ? $xliffNode->attributes->getNamedItem('srcLang')->nodeValue : 'en-US';
70 70
 
71 71
         // datatype
72 72
         // @TODO to be implemented
73 73
 
74 74
         // target-language
75
-        $metadata[ 'target-language' ] = (null !== $xliffNode->attributes->getNamedItem('trgLang')) ? $xliffNode->attributes->getNamedItem('trgLang')->nodeValue : 'en-US';
75
+        $metadata['target-language'] = (null !== $xliffNode->attributes->getNamedItem('trgLang')) ? $xliffNode->attributes->getNamedItem('trgLang')->nodeValue : 'en-US';
76 76
 
77 77
         // custom MateCat x-attribute
78 78
         // @TODO to be implemented
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      * @return array
87 87
      * @throws \Exception
88 88
      */
89
-    private function extractNotes( DOMElement $file)
89
+    private function extractNotes(DOMElement $file)
90 90
     {
91 91
         $notes = [];
92 92
 
@@ -120,16 +120,16 @@  discard block
 block discarded – undo
120 120
     protected function extractTransUnit($transUnit, &$transUnitIdArrayForUniquenessCheck, $dom, &$output, &$i, &$j)
121 121
     {
122 122
         // metadata
123
-        $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'attr' ] = $this->extractTransUnitMetadata($transUnit, $transUnitIdArrayForUniquenessCheck);
123
+        $output['files'][$i]['trans-units'][$j]['attr'] = $this->extractTransUnitMetadata($transUnit, $transUnitIdArrayForUniquenessCheck);
124 124
 
125 125
         // notes
126 126
         // merge <notes> with key and key-note contained in metadata <mda:metaGroup>
127
-        $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'notes' ] = $this->extractTransUnitNotes($transUnit);
127
+        $output['files'][$i]['trans-units'][$j]['notes'] = $this->extractTransUnitNotes($transUnit);
128 128
 
129 129
         // uuid
130
-        foreach ($output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'notes' ] as $note){
131
-            if(isset($note['raw-content']) && Strings::isAValidUuid($note['raw-content'])){
132
-                $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'attr' ]['uuid'] = $note['raw-content'];
130
+        foreach ($output['files'][$i]['trans-units'][$j]['notes'] as $note) {
131
+            if (isset($note['raw-content']) && Strings::isAValidUuid($note['raw-content'])) {
132
+                $output['files'][$i]['trans-units'][$j]['attr']['uuid'] = $note['raw-content'];
133 133
             }
134 134
         }
135 135
 
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
         // http://docs.oasis-open.org/xliff/xliff-core/v2.0/xliff-core-v2.0.html#originaldata
138 138
         $originalData = $this->extractTransUnitOriginalData($transUnit);
139 139
         if (!empty($originalData)) {
140
-            $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'original-data' ] = $originalData;
140
+            $output['files'][$i]['trans-units'][$j]['original-data'] = $originalData;
141 141
             $dataRefMap = $this->getDataRefMap($originalData);
142 142
         }
143 143
 
144 144
         // additionalTagData (exclusive for V2)
145 145
         $additionalTagData = $this->extractTransUnitAdditionalTagData($transUnit);
146 146
         if (!empty($additionalTagData)) {
147
-            $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'additional-tag-data' ] = $additionalTagData;
147
+            $output['files'][$i]['trans-units'][$j]['additional-tag-data'] = $additionalTagData;
148 148
         }
149 149
 
150 150
         // content
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
             if ($segment->nodeName === 'segment') {
169 169
 
170 170
                 // check segment id consistency
171
-                $attr = $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'attr' ];
171
+                $attr = $output['files'][$i]['trans-units'][$j]['attr'];
172 172
                 $this->checkSegmentIdConsistency($segment, $attr);
173 173
 
174 174
                 // loop <segment> to get nested <source> and <target> tag
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
                                 'mid'           => count($segSource) > 0 ? count($segSource) : 0,
194 194
                                 'ext-prec-tags' => '',
195 195
                                 'raw-content'   => $extractedSource['raw-content'],
196
-                                'replaced-content'   => (!empty($originalData)) ?  (new DataRefReplacer($dataRefMap))->replace($extractedSource['raw-content']) : null,
196
+                                'replaced-content'   => (!empty($originalData)) ? (new DataRefReplacer($dataRefMap))->replace($extractedSource['raw-content']) : null,
197 197
                                 'ext-succ-tags' => '',
198 198
                             ];
199 199
                         }
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
                                 'mid'           => count($segTarget) > 0 ? count($segTarget) : 0,
220 220
                                 'ext-prec-tags' => '',
221 221
                                 'raw-content'   => $extractedTarget['raw-content'],
222
-                                'replaced-content' => (!empty($originalData)) ?  (new DataRefReplacer($dataRefMap))->replace($extractedTarget['raw-content']) : null,
222
+                                'replaced-content' => (!empty($originalData)) ? (new DataRefReplacer($dataRefMap))->replace($extractedTarget['raw-content']) : null,
223 223
                                 'ext-succ-tags' => '',
224 224
                             ];
225 225
                         }
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
             }
231 231
         }
232 232
 
233
-        $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'source' ] = $source;
234
-        $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'target' ] = $target;
235
-        $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'seg-source' ] = $segSource;
236
-        $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'seg-target' ] = $segTarget;
233
+        $output['files'][$i]['trans-units'][$j]['source'] = $source;
234
+        $output['files'][$i]['trans-units'][$j]['target'] = $target;
235
+        $output['files'][$i]['trans-units'][$j]['seg-source'] = $segSource;
236
+        $output['files'][$i]['trans-units'][$j]['seg-target'] = $segTarget;
237 237
 
238 238
         $j++;
239 239
     }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
      *
245 245
      * @return array
246 246
      */
247
-    private function extractTransUnitMetadata( DOMElement $transUnit, &$transUnitIdArrayForUniquenessCheck)
247
+    private function extractTransUnitMetadata(DOMElement $transUnit, &$transUnitIdArrayForUniquenessCheck)
248 248
     {
249 249
         $metadata = [];
250 250
 
@@ -255,31 +255,31 @@  discard block
 block discarded – undo
255 255
 
256 256
         $id = $transUnit->attributes->getNamedItem('id')->nodeValue;
257 257
 
258
-        if(strlen($id) > 100){
258
+        if (strlen($id) > 100) {
259 259
             throw new SegmentIdTooLongException('Segment-id too long. Max 100 characters allowed', 400);
260 260
         }
261 261
 
262 262
         $transUnitIdArrayForUniquenessCheck[] = $id;
263
-        $metadata[ 'id' ] = $id;
263
+        $metadata['id'] = $id;
264 264
 
265 265
         // translate
266 266
         if (null !== $transUnit->attributes->getNamedItem('translate')) {
267
-            $metadata[ 'translate' ] = $transUnit->attributes->getNamedItem('translate')->nodeValue;
267
+            $metadata['translate'] = $transUnit->attributes->getNamedItem('translate')->nodeValue;
268 268
         }
269 269
 
270 270
         // tGroupBegin
271 271
         if (null !== $transUnit->attributes->getNamedItem('tGroupBegin')) {
272
-            $metadata[ 'tGroupBegin' ] = $transUnit->attributes->getNamedItem('tGroupBegin')->nodeValue;
272
+            $metadata['tGroupBegin'] = $transUnit->attributes->getNamedItem('tGroupBegin')->nodeValue;
273 273
         }
274 274
 
275 275
         // tGroupEnd
276 276
         if (null !== $transUnit->attributes->getNamedItem('tGroupEnd')) {
277
-            $metadata[ 'tGroupEnd' ] = $transUnit->attributes->getNamedItem('tGroupEnd')->nodeValue;
277
+            $metadata['tGroupEnd'] = $transUnit->attributes->getNamedItem('tGroupEnd')->nodeValue;
278 278
         }
279 279
 
280 280
         // sizeRestriction
281
-        if (null !== $transUnit->attributes->getNamedItem('sizeRestriction') &&  '' !== $transUnit->attributes->getNamedItem('sizeRestriction')->nodeValue ) {
282
-            $metadata[ 'sizeRestriction' ] = (int)$transUnit->attributes->getNamedItem('sizeRestriction')->nodeValue;
281
+        if (null !== $transUnit->attributes->getNamedItem('sizeRestriction') && '' !== $transUnit->attributes->getNamedItem('sizeRestriction')->nodeValue) {
282
+            $metadata['sizeRestriction'] = (int)$transUnit->attributes->getNamedItem('sizeRestriction')->nodeValue;
283 283
         }
284 284
 
285 285
         return $metadata;
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
      * @return array
292 292
      * @throws \Exception
293 293
      */
294
-    private function extractTransUnitOriginalData( DOMElement $transUnit)
294
+    private function extractTransUnitOriginalData(DOMElement $transUnit)
295 295
     {
296 296
         $originalData = [];
297 297
 
@@ -299,11 +299,11 @@  discard block
 block discarded – undo
299 299
         foreach ($transUnit->childNodes as $childNode) {
300 300
             if ($childNode->nodeName === 'originalData') {
301 301
                 foreach ($childNode->childNodes as $data) {
302
-                    if (null!== $data->attributes && null !== $data->attributes->getNamedItem('id')) {
302
+                    if (null !== $data->attributes && null !== $data->attributes->getNamedItem('id')) {
303 303
                         $dataId = $data->attributes->getNamedItem('id')->nodeValue;
304 304
 
305 305
                         $dataValue = str_replace(Placeholder::WHITE_SPACE_PLACEHOLDER, ' ', $data->nodeValue);
306
-                        $dataValue = str_replace(Placeholder::NEW_LINE_PLACEHOLDER,'\n', $dataValue);
306
+                        $dataValue = str_replace(Placeholder::NEW_LINE_PLACEHOLDER, '\n', $dataValue);
307 307
                         $dataValue = str_replace(Placeholder::TAB_PLACEHOLDER, '\t', $dataValue);
308 308
 
309 309
                         if ('' !== $dataValue) {
@@ -311,12 +311,12 @@  discard block
 block discarded – undo
311 311
                             $jsonOrRawContentArray = $this->JSONOrRawContentArray($dataValue, false);
312 312
 
313 313
                             // restore xliff tags
314
-                            if (isset($jsonOrRawContentArray['json'])){
315
-                                $jsonOrRawContentArray['json'] = str_replace([Placeholder::LT_PLACEHOLDER, Placeholder::GT_PLACEHOLDER], ['&lt;','&gt;'], $jsonOrRawContentArray['json']);
314
+                            if (isset($jsonOrRawContentArray['json'])) {
315
+                                $jsonOrRawContentArray['json'] = str_replace([Placeholder::LT_PLACEHOLDER, Placeholder::GT_PLACEHOLDER], ['&lt;', '&gt;'], $jsonOrRawContentArray['json']);
316 316
                             }
317 317
 
318
-                            if (isset($jsonOrRawContentArray['raw-content'])){
319
-                                $jsonOrRawContentArray['raw-content'] = str_replace([Placeholder::LT_PLACEHOLDER, Placeholder::GT_PLACEHOLDER], ['&lt;','&gt;'], $jsonOrRawContentArray['raw-content']);
318
+                            if (isset($jsonOrRawContentArray['raw-content'])) {
319
+                                $jsonOrRawContentArray['raw-content'] = str_replace([Placeholder::LT_PLACEHOLDER, Placeholder::GT_PLACEHOLDER], ['&lt;', '&gt;'], $jsonOrRawContentArray['raw-content']);
320 320
                             }
321 321
 
322 322
                             $originalData[] = array_merge(
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
      *
342 342
      * @return array
343 343
      */
344
-    private function extractTransUnitAdditionalTagData( DOMElement $transUnit)
344
+    private function extractTransUnitAdditionalTagData(DOMElement $transUnit)
345 345
     {
346 346
         $additionalTagData = [];
347 347
 
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 
354 354
                     // id
355 355
                     if ($data->nodeName === 'memsource:tag') {
356
-                        if (null!== $data->attributes && null !== $data->attributes->getNamedItem('id')) {
356
+                        if (null !== $data->attributes && null !== $data->attributes->getNamedItem('id')) {
357 357
                             $dataId = $data->attributes->getNamedItem('id')->nodeValue;
358 358
                             $dataArray['attr']['id'] = $dataId;
359 359
                         }
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 
362 362
                     // in PHP 7.4 $data->childNodes is an empty DomNodeList, it is iterable with size 0
363 363
                     // PHP 5.6 check: in php 5.6 $data->childNodes can be null
364
-                    if( $data->childNodes != null ){
364
+                    if ($data->childNodes != null) {
365 365
 
366 366
                         // content
367 367
                         foreach ($data->childNodes as $datum) {
@@ -392,12 +392,12 @@  discard block
 block discarded – undo
392 392
      * @param DOMElement $segment
393 393
      * @param array $attr
394 394
      */
395
-    private function checkSegmentIdConsistency( DOMElement $segment, array $attr)
395
+    private function checkSegmentIdConsistency(DOMElement $segment, array $attr)
396 396
     {
397
-        if (isset($attr[ 'tGroupBegin' ]) && isset($attr[ 'tGroupEnd' ]) && $segment->attributes->getNamedItem('id')) {
397
+        if (isset($attr['tGroupBegin']) && isset($attr['tGroupEnd']) && $segment->attributes->getNamedItem('id')) {
398 398
             $id = $segment->attributes->getNamedItem('id')->nodeValue;
399
-            $min = (int)$attr[ 'tGroupBegin' ];
400
-            $max = (int)$attr[ 'tGroupEnd' ];
399
+            $min = (int)$attr['tGroupBegin'];
400
+            $max = (int)$attr['tGroupEnd'];
401 401
 
402 402
             if (false === (($min <= $id) && ($id <= $max))) {
403 403
                 if ($this->logger) {
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
      * @return array
414 414
      * @throws \Exception
415 415
      */
416
-    private function extractTransUnitNotes( DOMElement $transUnit)
416
+    private function extractTransUnitNotes(DOMElement $transUnit)
417 417
     {
418 418
         $notes = [];
419 419
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
                 foreach ($childNode->childNodes as $metadata) {
433 433
                     if ($metadata->nodeName === 'mda:metaGroup') {
434 434
                         foreach ($metadata->childNodes as $meta) {
435
-                            if (null!== $meta->attributes && null !== $meta->attributes->getNamedItem('type')) {
435
+                            if (null !== $meta->attributes && null !== $meta->attributes->getNamedItem('type')) {
436 436
                                 $type = $meta->attributes->getNamedItem('type')->nodeValue;
437 437
                                 $metaValue = trim($meta->nodeValue);
438 438
 
Please login to merge, or discard this patch.