Passed
Push — master ( c6a496...f5104b )
by Domenico
03:00
created
src/XliffUtils/CheckPipeline/CheckMateCATConverter.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -8,20 +8,20 @@
 block discarded – undo
8 8
      *
9 9
      * @return array|null
10 10
      */
11
-    public function check( ?array $tmp = [] ): ?array {
11
+    public function check(?array $tmp = []): ?array {
12 12
         $fileType = [];
13 13
 
14
-        if ( isset( $tmp[ 0 ] ) ) {
15
-            preg_match( '#tool-id\s*=\s*"matecat-converter(\s+([^"]+))?"#i', $tmp[ 0 ], $matches );
16
-            if ( !empty( $matches ) ) {
17
-                $fileType[ 'proprietary' ]            = false;
18
-                $fileType[ 'proprietary_name' ]       = 'MateCAT Converter';
19
-                $fileType[ 'proprietary_short_name' ] = 'matecat_converter';
20
-                if ( isset( $matches[ 2 ] ) ) {
21
-                    $fileType[ 'converter_version' ] = $matches[ 2 ];
14
+        if (isset($tmp[0])) {
15
+            preg_match('#tool-id\s*=\s*"matecat-converter(\s+([^"]+))?"#i', $tmp[0], $matches);
16
+            if (!empty($matches)) {
17
+                $fileType['proprietary']            = false;
18
+                $fileType['proprietary_name']       = 'MateCAT Converter';
19
+                $fileType['proprietary_short_name'] = 'matecat_converter';
20
+                if (isset($matches[2])) {
21
+                    $fileType['converter_version'] = $matches[2];
22 22
                 } else {
23 23
                     // First converter release didn't specify version
24
-                    $fileType[ 'converter_version' ] = '1.0';
24
+                    $fileType['converter_version'] = '1.0';
25 25
                 }
26 26
 
27 27
                 return $fileType;
Please login to merge, or discard this patch.
src/XliffUtils/CheckPipeline/CheckXliffVersion2.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -8,22 +8,22 @@
 block discarded – undo
8 8
      *
9 9
      * @return array|null
10 10
      */
11
-    public function check( ?array $tmp = [] ): ?array {
11
+    public function check(?array $tmp = []): ?array {
12 12
         $fileType = [];
13 13
 
14
-        if ( isset( $tmp[ 0 ] ) ) {
15
-            preg_match( '|<xliff.*?\sversion\s?=\s?["\'](.*?)["\']|si', substr( $tmp[ 0 ], 0, 1000 ), $versionMatches );
16
-            preg_match( '|<xliff.*?\sxmlns\s?=\s?["\']urn:oasis:names:tc:xliff:document:(.*?)["\']|si', substr( $tmp[ 0 ], 0, 1000 ), $xmlnsMatches );
14
+        if (isset($tmp[0])) {
15
+            preg_match('|<xliff.*?\sversion\s?=\s?["\'](.*?)["\']|si', substr($tmp[0], 0, 1000), $versionMatches);
16
+            preg_match('|<xliff.*?\sxmlns\s?=\s?["\']urn:oasis:names:tc:xliff:document:(.*?)["\']|si', substr($tmp[0], 0, 1000), $xmlnsMatches);
17 17
 
18
-            if ( !empty( $versionMatches ) && !empty( $xmlnsMatches ) ) {
19
-                $version = $versionMatches[ 1 ];
20
-                $xmlns   = $xmlnsMatches[ 1 ];
18
+            if (!empty($versionMatches) && !empty($xmlnsMatches)) {
19
+                $version = $versionMatches[1];
20
+                $xmlns   = $xmlnsMatches[1];
21 21
 
22
-                if ( $version === $xmlns && $version >= 2 ) {
23
-                    $fileType[ 'proprietary' ]            = false;
24
-                    $fileType[ 'proprietary_name' ]       = 'Xliff v' . $version . ' File';
25
-                    $fileType[ 'proprietary_short_name' ] = 'xliff_v2';
26
-                    $fileType[ 'converter_version' ]      = '2.0';
22
+                if ($version === $xmlns && $version >= 2) {
23
+                    $fileType['proprietary']            = false;
24
+                    $fileType['proprietary_name']       = 'Xliff v' . $version . ' File';
25
+                    $fileType['proprietary_short_name'] = 'xliff_v2';
26
+                    $fileType['converter_version']      = '2.0';
27 27
 
28 28
                     return $fileType;
29 29
                 }
Please login to merge, or discard this patch.
src/XliffUtils/CheckPipeline/CheckInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,5 +8,5 @@
 block discarded – undo
8 8
      *
9 9
      * @return array|null
10 10
      */
11
-    public function check( ?array $tmp = [] ): ?array;
11
+    public function check(?array $tmp = []): ?array;
12 12
 }
Please login to merge, or discard this patch.
src/XliffUtils/XliffVersionDetector.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
     /**
10 10
      * @var array
11 11
      */
12
-    private static array $versions_1 = [ '1.0', '1.1', '1.2' ];
12
+    private static array $versions_1 = ['1.0', '1.1', '1.2'];
13 13
 
14 14
     /**
15 15
      * @var array
16 16
      */
17
-    private static array $versions_2 = [ '2.0', '2.1' ];
17
+    private static array $versions_2 = ['2.0', '2.1'];
18 18
 
19 19
     /**
20 20
      * @param string $xliffContent
@@ -23,16 +23,16 @@  discard block
 block discarded – undo
23 23
      * @throws NotSupportedVersionException
24 24
      * @throws NotValidFileException
25 25
      */
26
-    public static function detect( string $xliffContent ): int {
27
-        preg_match( '|<xliff.*?\sversion\s?=\s?["\'](.*?)["\']|si', substr( $xliffContent, 0, 1000 ), $versionMatches );
26
+    public static function detect(string $xliffContent): int {
27
+        preg_match('|<xliff.*?\sversion\s?=\s?["\'](.*?)["\']|si', substr($xliffContent, 0, 1000), $versionMatches);
28 28
 
29
-        if ( empty( $versionMatches ) ) {
30
-            throw new NotValidFileException( 'This is not a valid xliff file' );
29
+        if (empty($versionMatches)) {
30
+            throw new NotValidFileException('This is not a valid xliff file');
31 31
         }
32 32
 
33
-        $version = $versionMatches[ 1 ];
33
+        $version = $versionMatches[1];
34 34
 
35
-        return self::resolveVersion( $version );
35
+        return self::resolveVersion($version);
36 36
     }
37 37
 
38 38
     /**
@@ -41,15 +41,15 @@  discard block
 block discarded – undo
41 41
      * @return int
42 42
      * @throws NotSupportedVersionException
43 43
      */
44
-    private static function resolveVersion( string $version ): int {
45
-        if ( in_array( $version, self::$versions_1 ) ) {
44
+    private static function resolveVersion(string $version): int {
45
+        if (in_array($version, self::$versions_1)) {
46 46
             return 1;
47 47
         }
48 48
 
49
-        if ( in_array( $version, self::$versions_2 ) ) {
49
+        if (in_array($version, self::$versions_2)) {
50 50
             return 2;
51 51
         }
52 52
 
53
-        throw new NotSupportedVersionException( 'Not supported version' );
53
+        throw new NotSupportedVersionException('Not supported version');
54 54
     }
55 55
 }
Please login to merge, or discard this patch.
src/XliffReplacer/XliffReplacerFactory.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,14 +28,14 @@
 block discarded – undo
28 28
             ?LoggerInterface                $logger = null,
29 29
             ?XliffReplacerCallbackInterface $callback = null
30 30
     ): AbstractXliffReplacer {
31
-        $info = XliffProprietaryDetect::getInfo( $originalXliffPath );
31
+        $info = XliffProprietaryDetect::getInfo($originalXliffPath);
32 32
 
33
-        if ( $info[ 'version' ] == 1 && $info[ 'proprietary_short_name' ] !== 'trados' ) {
34
-            return new Xliff12( $originalXliffPath, $info[ 'version' ], $data, $transUnits, $targetLang, $outputFilePath, $setSourceInTarget, $logger, $callback );
35
-        } elseif ( $info[ 'version' ] == 2 ) {
36
-            return new Xliff20( $originalXliffPath, $info[ 'version' ], $data, $transUnits, $targetLang, $outputFilePath, $setSourceInTarget, $logger, $callback );
33
+        if ($info['version'] == 1 && $info['proprietary_short_name'] !== 'trados') {
34
+            return new Xliff12($originalXliffPath, $info['version'], $data, $transUnits, $targetLang, $outputFilePath, $setSourceInTarget, $logger, $callback);
35
+        } elseif ($info['version'] == 2) {
36
+            return new Xliff20($originalXliffPath, $info['version'], $data, $transUnits, $targetLang, $outputFilePath, $setSourceInTarget, $logger, $callback);
37 37
         }
38 38
 
39
-        return new XliffSdl( $originalXliffPath, $info[ 'version' ], $data, $transUnits, $targetLang, $outputFilePath, $setSourceInTarget, $logger, $callback );
39
+        return new XliffSdl($originalXliffPath, $info['version'], $data, $transUnits, $targetLang, $outputFilePath, $setSourceInTarget, $logger, $callback);
40 40
     }
41 41
 }
Please login to merge, or discard this patch.
src/XliffReplacer/XliffReplacerCallbackInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,5 +12,5 @@
 block discarded – undo
12 12
      *
13 13
      * @return bool
14 14
      */
15
-    public function thereAreErrors( int $segmentId, string $segment, string $translation, ?array $dataRefMap = [], ?string $error = null ): bool;
15
+    public function thereAreErrors(int $segmentId, string $segment, string $translation, ?array $dataRefMap = [], ?string $error = null): bool;
16 16
 }
Please login to merge, or discard this patch.
src/XliffReplacer/StatusToStateAttribute.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
             ?string $lastMrkState = null
27 27
     ): array {
28 28
 
29
-        $status       = empty( $status ) ? TranslationStatus::STATUS_TRANSLATED : $status;
29
+        $status = empty($status) ? TranslationStatus::STATUS_TRANSLATED : $status;
30 30
 
31 31
         $stateLevelsMap = [
32 32
                 TranslationStatus::STATUS_APPROVED2  => 100,
@@ -37,26 +37,26 @@  discard block
 block discarded – undo
37 37
                 TranslationStatus::STATUS_NEW        => 50
38 38
         ];
39 39
 
40
-        $orderedValues = array_flip( $stateLevelsMap );
40
+        $orderedValues = array_flip($stateLevelsMap);
41 41
 
42 42
         // Define state mappings for different statuses
43 43
         $stateMap = [
44
-                TranslationStatus::STATUS_APPROVED2  => [ "state=\"final\"", TranslationStatus::STATUS_APPROVED2 ],
44
+                TranslationStatus::STATUS_APPROVED2  => ["state=\"final\"", TranslationStatus::STATUS_APPROVED2],
45 45
                 TranslationStatus::STATUS_APPROVED   => [
46
-                        ( $xliffVersion === 2 ) ? "state=\"reviewed\"" : "state=\"signed-off\"",
46
+                        ($xliffVersion === 2) ? "state=\"reviewed\"" : "state=\"signed-off\"",
47 47
                         TranslationStatus::STATUS_APPROVED
48 48
                 ],
49
-                TranslationStatus::STATUS_TRANSLATED => [ "state=\"translated\"", TranslationStatus::STATUS_TRANSLATED ],
49
+                TranslationStatus::STATUS_TRANSLATED => ["state=\"translated\"", TranslationStatus::STATUS_TRANSLATED],
50 50
                 TranslationStatus::STATUS_REJECTED   => [
51
-                        ( $xliffVersion === 2 ) ? "state=\"initial\"" : "state=\"needs-review-translation\"",
51
+                        ($xliffVersion === 2) ? "state=\"initial\"" : "state=\"needs-review-translation\"",
52 52
                         TranslationStatus::STATUS_REJECTED
53 53
                 ],
54 54
                 TranslationStatus::STATUS_NEW        => [
55
-                        ( $xliffVersion === 2 ) ? "state=\"initial\"" : "state=\"new\"",
55
+                        ($xliffVersion === 2) ? "state=\"initial\"" : "state=\"new\"",
56 56
                         TranslationStatus::STATUS_NEW
57 57
                 ],
58 58
                 TranslationStatus::STATUS_DRAFT      => [
59
-                        ( $xliffVersion === 2 ) ? "state=\"initial\"" : "state=\"new\"",
59
+                        ($xliffVersion === 2) ? "state=\"initial\"" : "state=\"new\"",
60 60
                         TranslationStatus::STATUS_DRAFT
61 61
                 ],
62 62
         ];
@@ -67,14 +67,14 @@  discard block
 block discarded – undo
67 67
         // ---> $seg[ 'status' ] is NULL
68 68
         // If lastMrkState is empty
69 69
         $minStatus = min(
70
-                $stateLevelsMap[ $status ],
71
-                ( $stateLevelsMap[ $lastMrkState ] ?? $stateLevelsMap[ TranslationStatus::STATUS_NEW ] )
70
+                $stateLevelsMap[$status],
71
+                ($stateLevelsMap[$lastMrkState] ?? $stateLevelsMap[TranslationStatus::STATUS_NEW])
72 72
         );
73 73
 
74 74
         // If the last mark state is set, get the minimum value, otherwise get the current state
75
-        [ $state_prop, $lastMrkState ] = empty( $lastMrkState ) ? $stateMap[ $status ] : $stateMap[ $orderedValues[ $minStatus ] ];
75
+        [$state_prop, $lastMrkState] = empty($lastMrkState) ? $stateMap[$status] : $stateMap[$orderedValues[$minStatus]];
76 76
 
77
-        return [ $state_prop, $lastMrkState ];
77
+        return [$state_prop, $lastMrkState];
78 78
 
79 79
     }
80 80
 
Please login to merge, or discard this patch.
src/XliffUtils/XliffProprietaryDetect.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
      *
23 23
      * @return array
24 24
      */
25
-    public static function getInfoFromXliffContent( string $xliffContent ): array {
25
+    public static function getInfoFromXliffContent(string $xliffContent): array {
26 26
         self::reset();
27
-        $tmp = self::getFirst1024CharsFromXliff( $xliffContent );
27
+        $tmp = self::getFirst1024CharsFromXliff($xliffContent);
28 28
 
29
-        return self::getInfoFromTmp( $tmp );
29
+        return self::getInfoFromTmp($tmp);
30 30
     }
31 31
 
32 32
     /**
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
      *
35 35
      * @return array
36 36
      */
37
-    public static function getInfo( string $fullPathToFile ): array {
37
+    public static function getInfo(string $fullPathToFile): array {
38 38
         self::reset();
39
-        $tmp                      = self::getFirst1024CharsFromXliff( null, $fullPathToFile );
40
-        self::$fileType[ 'info' ] = Files::pathInfo( $fullPathToFile );
39
+        $tmp                      = self::getFirst1024CharsFromXliff(null, $fullPathToFile);
40
+        self::$fileType['info'] = Files::pathInfo($fullPathToFile);
41 41
 
42
-        return self::getInfoFromTmp( $tmp );
42
+        return self::getInfoFromTmp($tmp);
43 43
     }
44 44
 
45 45
     /**
@@ -47,21 +47,21 @@  discard block
 block discarded – undo
47 47
      *
48 48
      * @return array
49 49
      */
50
-    private static function getInfoFromTmp( array $tmp ): array {
50
+    private static function getInfoFromTmp(array $tmp): array {
51 51
         try {
52
-            self::checkVersion( $tmp );
53
-        } catch ( Exception $ignore ) {
52
+            self::checkVersion($tmp);
53
+        } catch (Exception $ignore) {
54 54
             // do nothing
55 55
             // self::$fileType[ 'version' ] is left empty
56 56
         }
57 57
 
58 58
         // run CheckXliffProprietaryPipeline
59
-        $pipeline = self::runPipeline( $tmp );
59
+        $pipeline = self::runPipeline($tmp);
60 60
 
61
-        self::$fileType[ 'proprietary' ]            = $pipeline[ 'proprietary' ];
62
-        self::$fileType[ 'proprietary_name' ]       = $pipeline[ 'proprietary_name' ];
63
-        self::$fileType[ 'proprietary_short_name' ] = $pipeline[ 'proprietary_short_name' ];
64
-        self::$fileType[ 'converter_version' ]      = $pipeline[ 'converter_version' ];
61
+        self::$fileType['proprietary']            = $pipeline['proprietary'];
62
+        self::$fileType['proprietary_name']       = $pipeline['proprietary_name'];
63
+        self::$fileType['proprietary_short_name'] = $pipeline['proprietary_short_name'];
64
+        self::$fileType['converter_version']      = $pipeline['converter_version'];
65 65
 
66 66
         return self::$fileType;
67 67
     }
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
      *
72 72
      * @return array
73 73
      */
74
-    private static function runPipeline( ?array $tmp = [] ): array {
75
-        $pipeline = new CheckXliffProprietaryPipeline( $tmp );
76
-        $pipeline->addCheck( new CheckSDL() );
77
-        $pipeline->addCheck( new CheckGlobalSight() );
78
-        $pipeline->addCheck( new CheckMateCATConverter() );
79
-        $pipeline->addCheck( new CheckXliffVersion2() );
74
+    private static function runPipeline(?array $tmp = []): array {
75
+        $pipeline = new CheckXliffProprietaryPipeline($tmp);
76
+        $pipeline->addCheck(new CheckSDL());
77
+        $pipeline->addCheck(new CheckGlobalSight());
78
+        $pipeline->addCheck(new CheckMateCATConverter());
79
+        $pipeline->addCheck(new CheckXliffVersion2());
80 80
 
81 81
         return $pipeline->run();
82 82
     }
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
      *
99 99
      * @return string
100 100
      */
101
-    private static function getFirst1024CharsFromString( ?string $stringData ): string {
102
-        if ( !empty( $stringData ) ) {
103
-            return substr( $stringData, 0, 1024 );
101
+    private static function getFirst1024CharsFromString(?string $stringData): string {
102
+        if (!empty($stringData)) {
103
+            return substr($stringData, 0, 1024);
104 104
         }
105 105
 
106 106
         return '';
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
      *
112 112
      * @return string
113 113
      */
114
-    private static function getFirst1024CharsFromFile( ?string $fullPathToFile ): string {
114
+    private static function getFirst1024CharsFromFile(?string $fullPathToFile): string {
115 115
         $stringData = '';
116
-        if ( !empty( $fullPathToFile ) && is_file( $fullPathToFile ) ) {
117
-            $file_pointer = fopen( "$fullPathToFile", 'r' );
116
+        if (!empty($fullPathToFile) && is_file($fullPathToFile)) {
117
+            $file_pointer = fopen("$fullPathToFile", 'r');
118 118
             // Checking Requirements (By specs, I know that xliff version is in the first 1KB)
119
-            $stringData = fread( $file_pointer, 1024 );
120
-            fclose( $file_pointer );
119
+            $stringData = fread($file_pointer, 1024);
120
+            fclose($file_pointer);
121 121
         }
122 122
 
123 123
         return $stringData;
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
      *
131 131
      * @return string[]
132 132
      */
133
-    private static function getFirst1024CharsFromXliff( ?string $stringData = null, string $fullPathToFile = null ): ?array {
134
-        $stringData = static::getFirst1024CharsFromString( $stringData );
135
-        if ( empty( $stringData ) ) {
136
-            $stringData = static::getFirst1024CharsFromFile( $fullPathToFile );
133
+    private static function getFirst1024CharsFromXliff(?string $stringData = null, string $fullPathToFile = null): ?array {
134
+        $stringData = static::getFirst1024CharsFromString($stringData);
135
+        if (empty($stringData)) {
136
+            $stringData = static::getFirst1024CharsFromFile($fullPathToFile);
137 137
         }
138 138
 
139
-        return !empty( $stringData ) ? [ $stringData ] : [];
139
+        return !empty($stringData) ? [$stringData] : [];
140 140
     }
141 141
 
142 142
     /**
@@ -145,9 +145,9 @@  discard block
 block discarded – undo
145 145
      * @throws NotSupportedVersionException
146 146
      * @throws NotValidFileException
147 147
      */
148
-    protected static function checkVersion( array $tmp ) {
149
-        if ( isset( $tmp[ 0 ] ) ) {
150
-            self::$fileType[ 'version' ] = XliffVersionDetector::detect( $tmp[ 0 ] );
148
+    protected static function checkVersion(array $tmp) {
149
+        if (isset($tmp[0])) {
150
+            self::$fileType['version'] = XliffVersionDetector::detect($tmp[0]);
151 151
         }
152 152
     }
153 153
 
@@ -158,20 +158,20 @@  discard block
 block discarded – undo
158 158
      * @throws NotSupportedVersionException
159 159
      * @throws NotValidFileException
160 160
      */
161
-    public static function getInfoByStringData( string $stringData ): array {
161
+    public static function getInfoByStringData(string $stringData): array {
162 162
         self::reset();
163 163
 
164
-        $tmp                      = self::getFirst1024CharsFromXliff( $stringData );
165
-        self::$fileType[ 'info' ] = [];
166
-        self::checkVersion( $tmp );
164
+        $tmp                      = self::getFirst1024CharsFromXliff($stringData);
165
+        self::$fileType['info'] = [];
166
+        self::checkVersion($tmp);
167 167
 
168 168
         // run CheckXliffProprietaryPipeline
169
-        $pipeline = self::runPipeline( $tmp );
169
+        $pipeline = self::runPipeline($tmp);
170 170
 
171
-        self::$fileType[ 'proprietary' ]            = $pipeline[ 'proprietary' ];
172
-        self::$fileType[ 'proprietary_name' ]       = $pipeline[ 'proprietary_name' ];
173
-        self::$fileType[ 'proprietary_short_name' ] = $pipeline[ 'proprietary_short_name' ];
174
-        self::$fileType[ 'converter_version' ]      = $pipeline[ 'converter_version' ];
171
+        self::$fileType['proprietary']            = $pipeline['proprietary'];
172
+        self::$fileType['proprietary_name']       = $pipeline['proprietary_name'];
173
+        self::$fileType['proprietary_short_name'] = $pipeline['proprietary_short_name'];
174
+        self::$fileType['converter_version']      = $pipeline['converter_version'];
175 175
 
176 176
         return self::$fileType;
177 177
     }
@@ -183,33 +183,33 @@  discard block
 block discarded – undo
183 183
      *
184 184
      * @return bool|int
185 185
      */
186
-    public static function fileMustBeConverted( string $fullPath, bool $enforceOnXliff = false, ?string $filterAddress = null ) {
186
+    public static function fileMustBeConverted(string $fullPath, bool $enforceOnXliff = false, ?string $filterAddress = null) {
187 187
         $convert = true;
188 188
 
189
-        $fileType       = self::getInfo( $fullPath );
190
-        $memoryFileType = Files::getMemoryFileType( $fullPath );
189
+        $fileType       = self::getInfo($fullPath);
190
+        $memoryFileType = Files::getMemoryFileType($fullPath);
191 191
 
192
-        if ( Files::isXliff( $fullPath ) || $memoryFileType ) {
193
-            if ( !empty( $filterAddress ) ) {
192
+        if (Files::isXliff($fullPath) || $memoryFileType) {
193
+            if (!empty($filterAddress)) {
194 194
 
195 195
                 //conversion enforce
196
-                if ( !$enforceOnXliff ) {
196
+                if (!$enforceOnXliff) {
197 197
 
198 198
                     //if file is not proprietary AND Enforce is disabled
199 199
                     //we take it as is
200
-                    if ( !$fileType[ 'proprietary' ] || $memoryFileType ) {
200
+                    if (!$fileType['proprietary'] || $memoryFileType) {
201 201
                         $convert = false;
202 202
                         //ok don't convert a standard sdlxliff
203 203
                     }
204 204
                 } else {
205 205
                     //if conversion enforce is active
206 206
                     //we force all xliff files but not files produced by SDL Studio because we can handle them
207
-                    if ( in_array( $fileType[ 'proprietary_short_name' ], [ 'matecat_converter', 'trados', 'xliff_v2' ] ) || $memoryFileType ) {
207
+                    if (in_array($fileType['proprietary_short_name'], ['matecat_converter', 'trados', 'xliff_v2']) || $memoryFileType) {
208 208
                         $convert = false;
209 209
                         //ok don't convert a standard sdlxliff
210 210
                     }
211 211
                 }
212
-            } elseif ( $fileType[ 'proprietary' ] ) {
212
+            } elseif ($fileType['proprietary']) {
213 213
 
214 214
                 /**
215 215
                  * Application misconfiguration.
Please login to merge, or discard this patch.
src/XliffReplacer/XliffSdl.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -16,38 +16,38 @@  discard block
 block discarded – undo
16 16
     /**
17 17
      * @inheritDoc
18 18
      */
19
-    protected function tagOpen( $parser, string $name, array $attr ) {
19
+    protected function tagOpen($parser, string $name, array $attr) {
20 20
 
21
-        $this->handleOpenUnit( $name, $attr );
21
+        $this->handleOpenUnit($name, $attr);
22 22
 
23 23
         // check if we are entering into a <target>
24
-        $this->checkSetInTarget( $name );
24
+        $this->checkSetInTarget($name);
25 25
 
26 26
         // reset Marker positions
27
-        if ( 'sdl:seg-defs' == $name ) {
27
+        if ('sdl:seg-defs' == $name) {
28 28
             $this->segmentInUnitPosition = 0;
29 29
         }
30 30
 
31 31
         // open buffer
32
-        $this->setInBuffer( $name );
32
+        $this->setInBuffer($name);
33 33
 
34 34
         // check if we are inside a <target>, obviously this happen only if there are targets inside the trans-unit
35 35
         // <target> must be stripped to be replaced, so this check avoids <target> reconstruction
36
-        if ( !$this->inTarget ) {
36
+        if (!$this->inTarget) {
37 37
 
38 38
             // costruct tag
39 39
             $tag = "<$name ";
40 40
 
41
-            foreach ( $attr as $k => $v ) {
41
+            foreach ($attr as $k => $v) {
42 42
 
43 43
                 // if tag name is file, we must replace the target-language attribute
44
-                if ( $name == 'file' && $k == 'target-language' && !empty( $this->targetLang ) ) {
44
+                if ($name == 'file' && $k == 'target-language' && !empty($this->targetLang)) {
45 45
                     //replace Target language with job language provided from constructor
46 46
                     $tag .= "$k=\"$this->targetLang\" ";
47 47
                 } else {
48 48
                     //normal tag flux, put attributes in it
49 49
                     // Warning, this is NOT an elseif
50
-                    if ( $k != 'conf' ) {
50
+                    if ($k != 'conf') {
51 51
                         //put also the current attribute in it if it is not a "conf" attribute
52 52
                         $tag .= "$k=\"$v\" ";
53 53
                     }
@@ -56,11 +56,11 @@  discard block
 block discarded – undo
56 56
 
57 57
             $seg = $this->getCurrentSegment();
58 58
 
59
-            if ( 'sdl:seg' == $name && !empty( $seg ) && isset( $seg[ 'sid' ] ) ) {
60
-                $tag .= $this->prepareTargetStatuses( $seg );
59
+            if ('sdl:seg' == $name && !empty($seg) && isset($seg['sid'])) {
60
+                $tag .= $this->prepareTargetStatuses($seg);
61 61
             }
62 62
 
63
-            $this->checkForSelfClosedTagAndFlush( $parser, $tag );
63
+            $this->checkForSelfClosedTagAndFlush($parser, $tag);
64 64
 
65 65
         }
66 66
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      *
72 72
      * @return string
73 73
      */
74
-    protected function prepareTargetStatuses( $segment ): string {
74
+    protected function prepareTargetStatuses($segment): string {
75 75
         $statusMap = [
76 76
                 'NEW'        => '',
77 77
                 'DRAFT'      => 'Draft',
@@ -81,19 +81,19 @@  discard block
 block discarded – undo
81 81
                 'REJECTED'   => 'RejectedTranslation',
82 82
         ];
83 83
 
84
-        return "conf=\"{$statusMap[ $segment[ 'status' ] ]}\" ";
84
+        return "conf=\"{$statusMap[$segment['status']]}\" ";
85 85
     }
86 86
 
87
-    protected function rebuildMarks( array $seg, string $translation ): string {
87
+    protected function rebuildMarks(array $seg, string $translation): string {
88 88
 
89
-        $trailingSpaces = str_repeat( ' ', Strings::getTheNumberOfTrailingSpaces( $translation ) );
89
+        $trailingSpaces = str_repeat(' ', Strings::getTheNumberOfTrailingSpaces($translation));
90 90
 
91
-        if ( $seg[ 'mrk_id' ] !== null && $seg[ 'mrk_id' ] != '' ) {
92
-            if ( $this->targetLang === 'ja-JP' ) {
93
-                $seg[ 'mrk_succ_tags' ] = ltrim( $seg[ 'mrk_succ_tags' ] );
91
+        if ($seg['mrk_id'] !== null && $seg['mrk_id'] != '') {
92
+            if ($this->targetLang === 'ja-JP') {
93
+                $seg['mrk_succ_tags'] = ltrim($seg['mrk_succ_tags']);
94 94
             }
95 95
 
96
-            $translation = "<mrk mid=\"" . $seg[ 'mrk_id' ] . "\" mtype=\"seg\">" . $seg[ 'mrk_prev_tags' ] . rtrim( $translation ) . $seg[ 'mrk_succ_tags' ] . "</mrk>" . $trailingSpaces;
96
+            $translation = "<mrk mid=\"" . $seg['mrk_id'] . "\" mtype=\"seg\">" . $seg['mrk_prev_tags'] . rtrim($translation) . $seg['mrk_succ_tags'] . "</mrk>" . $trailingSpaces;
97 97
         }
98 98
 
99 99
         return $translation;
Please login to merge, or discard this patch.