Passed
Push — master ( e8c874...e40a60 )
by Domenico
03:39 queued 12s
created
src/XliffParser/AbstractXliffParser.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
      * @param string|null          $xliffProprietary
33 33
      * @param LoggerInterface|null $logger
34 34
      */
35
-    public function __construct( $xliffVersion, $xliffProprietary = null, LoggerInterface $logger = null)
35
+    public function __construct($xliffVersion, $xliffProprietary = null, LoggerInterface $logger = null)
36 36
     {
37 37
         $this->xliffVersion = $xliffVersion;
38 38
         $this->logger       = $logger;
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
         if ($element->hasAttributes()) {
128 128
             foreach ($element->attributes as $attr) {
129
-                $tagAttributes[ $attr->nodeName ] = $attr->nodeValue;
129
+                $tagAttributes[$attr->nodeName] = $attr->nodeValue;
130 130
             }
131 131
         }
132 132
 
@@ -175,40 +175,40 @@  discard block
 block discarded – undo
175 175
         $markers = preg_split('#<mrk\s#si', $raw, -1);
176 176
 
177 177
         $mi = 0;
178
-        while (isset($markers[ $mi + 1 ])) {
178
+        while (isset($markers[$mi + 1])) {
179 179
             unset($mid);
180 180
 
181
-            preg_match('|mid\s?=\s?["\'](.*?)["\']|si', $markers[ $mi + 1 ], $mid);
181
+            preg_match('|mid\s?=\s?["\'](.*?)["\']|si', $markers[$mi + 1], $mid);
182 182
 
183 183
             // if it's a Trados file the trailing spaces after </mrk> are meaningful
184 184
             // so we add them to
185 185
             $trailingSpaces = '';
186
-            if($this->xliffProprietary === 'trados'){
187
-                preg_match_all('/<\/mrk>[\s]+/iu', $markers[ $mi + 1 ], $trailingSpacesMatches);
186
+            if ($this->xliffProprietary === 'trados') {
187
+                preg_match_all('/<\/mrk>[\s]+/iu', $markers[$mi + 1], $trailingSpacesMatches);
188 188
 
189
-                if(isset($trailingSpacesMatches[0]) and count($trailingSpacesMatches[0]) > 0){
190
-                    foreach ($trailingSpacesMatches[0] as $match){
189
+                if (isset($trailingSpacesMatches[0]) and count($trailingSpacesMatches[0]) > 0) {
190
+                    foreach ($trailingSpacesMatches[0] as $match) {
191 191
                         $trailingSpaces = str_replace('</mrk>', '', $match);
192 192
                     }
193 193
                 }
194 194
             }
195 195
 
196 196
             //re-build the mrk tag after the split
197
-            $originalMark = trim('<mrk ' . $markers[ $mi + 1 ]);
197
+            $originalMark = trim('<mrk ' . $markers[$mi + 1]);
198 198
 
199 199
             $mark_string  = preg_replace('#^<mrk\s[^>]+>(.*)#', '$1', $originalMark); // at this point we have: ---> 'Test </mrk> </g>>'
200 200
             $mark_content = preg_split('#</mrk>#si', $mark_string);
201 201
 
202 202
             $sourceArray = [
203
-                'mid' => (isset($mid[ 1 ])) ? $mid[ 1 ] : $mi,
204
-                'ext-prec-tags' => ($mi == 0 ? $markers[ 0 ] : ""),
205
-                'raw-content' => (isset($mark_content[ 0 ])) ? $mark_content[ 0 ].$trailingSpaces : '',
206
-                'ext-succ-tags' => (isset($mark_content[ 1 ])) ? $mark_content[ 1 ] : '',
203
+                'mid' => (isset($mid[1])) ? $mid[1] : $mi,
204
+                'ext-prec-tags' => ($mi == 0 ? $markers[0] : ""),
205
+                'raw-content' => (isset($mark_content[0])) ? $mark_content[0] . $trailingSpaces : '',
206
+                'ext-succ-tags' => (isset($mark_content[1])) ? $mark_content[1] : '',
207 207
             ];
208 208
 
209 209
             if (!empty($originalData)) {
210 210
                 $dataRefMap = $this->getDataRefMap($originalData);
211
-                $sourceArray['replaced-content'] = (new DataRefReplacer($dataRefMap))->replace($mark_content[ 0 ]);
211
+                $sourceArray['replaced-content'] = (new DataRefReplacer($dataRefMap))->replace($mark_content[0]);
212 212
             }
213 213
 
214 214
             $source[] = $sourceArray;
Please login to merge, or discard this patch.
src/XliffParser/XliffParserV1.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
         foreach ($dom->getElementsByTagName('file') as $file) {
20 20
 
21 21
             // metadata
22
-            $output[ 'files' ][ $i ][ 'attr' ] = $this->extractMetadata($file);
22
+            $output['files'][$i]['attr'] = $this->extractMetadata($file);
23 23
 
24 24
             // reference
25 25
             if (!empty($this->extractReference($file))) {
26
-                $output[ 'files' ][ $i ][ 'reference' ] = $this->extractReference($file);
26
+                $output['files'][$i]['reference'] = $this->extractReference($file);
27 27
             }
28 28
 
29 29
             // trans-units
@@ -65,36 +65,36 @@  discard block
 block discarded – undo
65 65
             switch ($attribute->localName) {
66 66
                 // original
67 67
                 case 'original':
68
-                    $metadata[ 'original' ] = $attribute->value;
68
+                    $metadata['original'] = $attribute->value;
69 69
                     break;
70 70
 
71 71
                 // source-language
72 72
                 case 'source-language':
73
-                    $metadata[ 'source-language' ] = $attribute->value;
73
+                    $metadata['source-language'] = $attribute->value;
74 74
                     break;
75 75
 
76 76
                 // data-type
77 77
                 case 'datatype':
78
-                    $metadata[ 'data-type' ] = $attribute->value;
78
+                    $metadata['data-type'] = $attribute->value;
79 79
                     break;
80 80
 
81 81
                 // target-language
82 82
                 case 'target-language':
83
-                    $metadata[ 'target-language' ] = $attribute->value;
83
+                    $metadata['target-language'] = $attribute->value;
84 84
                     break;
85 85
             }
86 86
 
87 87
             // Custom MateCat x-Attribute
88 88
             preg_match('|x-(.*?)|si', $attribute->localName, $temp);
89
-            if (isset($temp[ 1 ])) {
90
-                $customAttr[ $attribute->localName ] = $attribute->value;
89
+            if (isset($temp[1])) {
90
+                $customAttr[$attribute->localName] = $attribute->value;
91 91
             }
92 92
             unset($temp);
93 93
 
94 94
             // Custom MateCat namespace Attribute mtc:
95 95
             preg_match('|mtc:(.*?)|si', $attribute->nodeName, $temp);
96
-            if (isset($temp[ 1 ])) {
97
-                $customAttr[ $attribute->nodeName ] = $attribute->value;
96
+            if (isset($temp[1])) {
97
+                $customAttr[$attribute->nodeName] = $attribute->value;
98 98
             }
99 99
             unset($temp);
100 100
 
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
             /** @var \DOMNode $childNode */
121 121
             foreach ($ref->childNodes as $childNode) {
122 122
                 if ($childNode->nodeName === 'internal-file') {
123
-                    $reference[ $order ][ 'form-type' ] = $childNode->attributes->getNamedItem('form')->nodeValue;
124
-                    $reference[ $order ][ 'base64' ]    = trim($childNode->nodeValue);
123
+                    $reference[$order]['form-type'] = $childNode->attributes->getNamedItem('form')->nodeValue;
124
+                    $reference[$order]['base64']    = trim($childNode->nodeValue);
125 125
                     $order++;
126 126
                 }
127 127
             }
@@ -145,51 +145,51 @@  discard block
 block discarded – undo
145 145
     protected function extractTransUnit($transUnit, &$transUnitIdArrayForUniquenessCheck, $dom, &$output, &$i, &$j)
146 146
     {
147 147
         // metadata
148
-        $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'attr' ] = $this->extractTransUnitMetadata($transUnit, $transUnitIdArrayForUniquenessCheck);
148
+        $output['files'][$i]['trans-units'][$j]['attr'] = $this->extractTransUnitMetadata($transUnit, $transUnitIdArrayForUniquenessCheck);
149 149
 
150 150
         // notes
151
-        $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'notes' ] = $this->extractTransUnitNotes($dom, $transUnit);
151
+        $output['files'][$i]['trans-units'][$j]['notes'] = $this->extractTransUnitNotes($dom, $transUnit);
152 152
 
153 153
         // content
154 154
         /** @var \DOMElement $childNode */
155 155
         foreach ($transUnit->childNodes as $childNode) {
156 156
             // source
157 157
             if ($childNode->nodeName === 'source') {
158
-                $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'source' ] = $this->extractContent($dom, $childNode);
158
+                $output['files'][$i]['trans-units'][$j]['source'] = $this->extractContent($dom, $childNode);
159 159
             }
160 160
 
161 161
             // seg-source
162 162
             if ($childNode->nodeName === 'seg-source') {
163
-                $rawSegment = $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'source' ]['raw-content'];
164
-                $output[ 'files' ][ $i ][ 'trans-units' ][ $j ]['seg-source'] = $this->extractContentWithMarksAndExtTags($dom, $childNode, $rawSegment);
163
+                $rawSegment = $output['files'][$i]['trans-units'][$j]['source']['raw-content'];
164
+                $output['files'][$i]['trans-units'][$j]['seg-source'] = $this->extractContentWithMarksAndExtTags($dom, $childNode, $rawSegment);
165 165
             }
166 166
 
167 167
             // target
168 168
             if ($childNode->nodeName === 'target') {
169
-                $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'target' ] = $this->extractContent($dom, $childNode);
169
+                $output['files'][$i]['trans-units'][$j]['target'] = $this->extractContent($dom, $childNode);
170 170
 
171 171
                 // seg-target
172
-                $targetRawContent = @$output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'target' ][ 'raw-content' ];
173
-                $segSource = @$output[ 'files' ][ $i ][ 'trans-units' ][ $j ]['seg-source'];
172
+                $targetRawContent = @$output['files'][$i]['trans-units'][$j]['target']['raw-content'];
173
+                $segSource = @$output['files'][$i]['trans-units'][$j]['seg-source'];
174 174
                 if (isset($targetRawContent) and !empty($targetRawContent) and isset($segSource) and count($segSource) > 0) {
175
-                    $output[ 'files' ][ $i ][ 'trans-units' ][ $j ]['seg-target'] = $this->extractContentWithMarksAndExtTags($dom, $childNode, $targetRawContent);
175
+                    $output['files'][$i]['trans-units'][$j]['seg-target'] = $this->extractContentWithMarksAndExtTags($dom, $childNode, $targetRawContent);
176 176
                 }
177 177
             }
178 178
 
179 179
             // locked
180 180
             if ($childNode->nodeName === 'sdl:seg') {
181
-                $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'locked' ] = $this->extractLocked($childNode);
181
+                $output['files'][$i]['trans-units'][$j]['locked'] = $this->extractLocked($childNode);
182 182
             }
183 183
         }
184 184
 
185 185
         // context-group
186 186
         foreach ($transUnit->getElementsByTagName('context-group') as $contextGroup) {
187
-            $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'context-group' ][] = $this->extractTransUnitContextGroup($dom, $contextGroup);
187
+            $output['files'][$i]['trans-units'][$j]['context-group'][] = $this->extractTransUnitContextGroup($dom, $contextGroup);
188 188
         }
189 189
 
190 190
         // alt-trans
191 191
         foreach ($transUnit->getElementsByTagName('alt-trans') as $altTrans) {
192
-            $output[ 'files' ][ $i ][ 'trans-units' ][ $j ][ 'alt-trans' ][] = $this->extractTransUnitAltTrans($altTrans);
192
+            $output['files'][$i]['trans-units'][$j]['alt-trans'][] = $this->extractTransUnitAltTrans($altTrans);
193 193
         }
194 194
 
195 195
         $j++;
@@ -213,22 +213,22 @@  discard block
 block discarded – undo
213 213
 
214 214
         $id = $transUnit->attributes->getNamedItem('id')->nodeValue;
215 215
 
216
-        if(strlen($id) > 100){
216
+        if (strlen($id) > 100) {
217 217
             throw new SegmentIdTooLongException('Segment-id too long. Max 100 characters allowed', 400);
218 218
         }
219 219
 
220 220
         $transUnitIdArrayForUniquenessCheck[] = $id;
221
-        $metadata[ 'id' ] = $id;
221
+        $metadata['id'] = $id;
222 222
 
223 223
         // translate
224 224
         if (null !== $transUnit->attributes->getNamedItem('translate')) {
225
-            $metadata[ 'translate' ] = $transUnit->attributes->getNamedItem('translate')->nodeValue;
225
+            $metadata['translate'] = $transUnit->attributes->getNamedItem('translate')->nodeValue;
226 226
         }
227 227
 
228 228
         // approved
229 229
         // http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#approved
230 230
         if (null !== $transUnit->attributes->getNamedItem('approved')) {
231
-            $metadata[ 'approved' ] = filter_var($transUnit->attributes->getNamedItem('approved')->nodeValue, FILTER_VALIDATE_BOOLEAN);
231
+            $metadata['approved'] = filter_var($transUnit->attributes->getNamedItem('approved')->nodeValue, FILTER_VALIDATE_BOOLEAN);
232 232
         }
233 233
 
234 234
         return $metadata;
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
                 $extractedNote = $this->JSONOrRawContentArray($noteValue);
253 253
 
254 254
                 // extract all the attributes
255
-                foreach ($note->attributes as $attribute){
255
+                foreach ($note->attributes as $attribute) {
256 256
                     $extractedNote[$attribute->name] = $attribute->value;
257 257
                 }
258 258
 
Please login to merge, or discard this patch.
src/XliffReplacer/XliffReplacerFactory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
     {
27 27
         $info = XliffProprietaryDetect::getInfo($originalXliffPath);
28 28
 
29
-        if ($info[ 'proprietary_short_name' ] !== 'trados') {
29
+        if ($info['proprietary_short_name'] !== 'trados') {
30 30
             return new XliffSAXTranslationReplacer($originalXliffPath, $info['version'], $data, $transUnits, $targetLang, $outputFilePath, $setSourceInTarget, $logger, $callback);
31 31
         }
32 32
 
Please login to merge, or discard this patch.
src/XliffReplacer/AbstractXliffReplacer.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -8,28 +8,28 @@  discard block
 block discarded – undo
8 8
 {
9 9
     protected $originalFP;
10 10
 
11
-    protected $tuTagName;                 // <trans-unit> (forXliff v 1.*) or <unit> (forXliff v 2.*)
12
-    protected $inTU                = false;  // flag to check whether we are in a <trans-unit>
13
-    protected $inTarget            = false;  // flag to check whether we are in a <target>, to ignore everything
14
-    protected $isEmpty             = false;  // flag to check whether we are in an empty tag (<tag/>)
15
-    protected $targetWasWritten    = false;  // flag to check is <target> was written in the current unit
16
-    protected $segmentPositionInTu = -1;  // the current position of segment in the current <unit> (forXliff v 2.*)
17
-
18
-    protected $CDATABuffer    = "";       // buffer for special tag
19
-    protected $bufferIsActive = false;    // buffer for special tag
20
-
21
-    protected $offset        = 0;         // offset for SAX pointer
22
-    protected $outputFP;                  // output stream pointer
23
-    protected $currentBuffer;             // the current piece of text it's been parsed
24
-    protected $len;                       // length of the currentBuffer
25
-    protected $segments;                  // array of translations
11
+    protected $tuTagName; // <trans-unit> (forXliff v 1.*) or <unit> (forXliff v 2.*)
12
+    protected $inTU                = false; // flag to check whether we are in a <trans-unit>
13
+    protected $inTarget            = false; // flag to check whether we are in a <target>, to ignore everything
14
+    protected $isEmpty             = false; // flag to check whether we are in an empty tag (<tag/>)
15
+    protected $targetWasWritten    = false; // flag to check is <target> was written in the current unit
16
+    protected $segmentPositionInTu = -1; // the current position of segment in the current <unit> (forXliff v 2.*)
17
+
18
+    protected $CDATABuffer    = ""; // buffer for special tag
19
+    protected $bufferIsActive = false; // buffer for special tag
20
+
21
+    protected $offset = 0; // offset for SAX pointer
22
+    protected $outputFP; // output stream pointer
23
+    protected $currentBuffer; // the current piece of text it's been parsed
24
+    protected $len; // length of the currentBuffer
25
+    protected $segments; // array of translations
26 26
     protected $lastTransUnit = [];
27
-    protected $currentTransUnitId;        // id of current <trans-unit>
27
+    protected $currentTransUnitId; // id of current <trans-unit>
28 28
     protected $currentTransUnitTranslate; // 'translate' attribute of current <trans-unit>
29
-    protected $currentSegmentArray = [];  // id of current <segment> (forXliff v 2.*)
30
-    protected $unitContainsMda = false;   // check if <unit> already contains a <mda:metadata> (forXliff v 2.*)
31
-    protected $hasWrittenCounts = false;  // check if <unit> already wrote segment counts (forXliff v 2.*)
32
-    protected $sourceAttributes = [];     // current <source> attributes (needed when handling xliff files without <target>)
29
+    protected $currentSegmentArray = []; // id of current <segment> (forXliff v 2.*)
30
+    protected $unitContainsMda = false; // check if <unit> already contains a <mda:metadata> (forXliff v 2.*)
31
+    protected $hasWrittenCounts = false; // check if <unit> already wrote segment counts (forXliff v 2.*)
32
+    protected $sourceAttributes = []; // current <source> attributes (needed when handling xliff files without <target>)
33 33
 
34 34
     protected $targetLang;
35 35
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
         return "§" .
96 96
                 substr(
97 97
                     str_replace(
98
-                        [ '+', '/' ],
98
+                        ['+', '/'],
99 99
                         '',
100 100
                         base64_encode(openssl_random_pseudo_bytes(10, $_crypto_strong))
101 101
                     ),
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
      */
135 135
     private function setTuTagName()
136 136
     {
137
-        $this->tuTagName = ($this->xliffVersion === 2) ? 'unit': 'trans-unit';
137
+        $this->tuTagName = ($this->xliffVersion === 2) ? 'unit' : 'trans-unit';
138 138
     }
139 139
 
140 140
     /**
Please login to merge, or discard this patch.
src/Constants/TranslationStatus.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
             self::STATUS_REJECTED   => 5,
25 25
             self::STATUS_FIXED      => 6,
26 26
             self::STATUS_REBUTTED   => 7
27
-    ] ;
27
+    ];
28 28
 
29 29
     public static $STATUSES = array(
30 30
             self::STATUS_NEW,
Please login to merge, or discard this patch.
src/Constants/XliffTags.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,5 +7,5 @@
 block discarded – undo
7 7
     /**
8 8
      * List of allowed Xliff tags
9 9
      */
10
-    public static $tags = [ 'g', 'x', 'bx', 'ex', 'bpt', 'ept', 'ph', 'pc', 'ec', 'sc', 'it', 'mrk' ];
10
+    public static $tags = ['g', 'x', 'bx', 'ex', 'bpt', 'ept', 'ph', 'pc', 'ec', 'sc', 'it', 'mrk'];
11 11
 }
12 12
\ No newline at end of file
Please login to merge, or discard this patch.
src/Utils/Strings.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public static function isJSON($string)
32 32
     {
33
-        if(is_numeric($string)){
33
+        if (is_numeric($string)) {
34 34
             return false;
35 35
         }
36 36
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      *
123 123
      * @return mixed|string
124 124
      */
125
-    public static function fixNonWellFormedXml( $content, $escapeStrings = true)
125
+    public static function fixNonWellFormedXml($content, $escapeStrings = true)
126 126
     {
127 127
         if (self::$find_xliff_tags_reg === null) {
128 128
             // Convert the list of tags in a regexp list, for example "g|x|bx|ex"
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 
150 150
         // Find all the XLIFF tags
151 151
         preg_match_all(self::$find_xliff_tags_reg, $content, $matches);
152
-        $tags = (array)$matches[ 0 ];
152
+        $tags = (array)$matches[0];
153 153
 
154 154
         // Prepare placeholders
155 155
         $tags_placeholders = [];
156 156
         for ($i = 0; $i < count($tags); $i++) {
157
-            $tag                       = $tags[ $i ];
158
-            $tags_placeholders[ $tag ] = "#@!XLIFF-TAG-$i!@#";
157
+            $tag                       = $tags[$i];
158
+            $tags_placeholders[$tag] = "#@!XLIFF-TAG-$i!@#";
159 159
         }
160 160
 
161 161
         // Replace all XLIFF tags with placeholders that will not be escaped
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         }
165 165
 
166 166
         // Escape the string with the remaining non-XLIFF tags
167
-        if($escapeStrings){
167
+        if ($escapeStrings) {
168 168
             $content = htmlspecialchars($content, ENT_NOQUOTES, 'UTF-8', false);
169 169
         }
170 170
 
@@ -224,12 +224,12 @@  discard block
 block discarded – undo
224 224
      */
225 225
     public static function htmlspecialchars_decode($string, $onlyEscapedEntities = false)
226 226
     {
227
-        if(false === $onlyEscapedEntities){
227
+        if (false === $onlyEscapedEntities) {
228 228
             return htmlspecialchars_decode($string, ENT_NOQUOTES);
229 229
         }
230 230
 
231 231
         return preg_replace_callback(self::$htmlEntityRegex,
232
-            function ($match){
232
+            function($match) {
233 233
                 return self::htmlspecialchars_decode($match[0]);
234 234
         }, $string);
235 235
     }
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
      *
247 247
      * @return bool
248 248
      */
249
-    public static function isADoubleEscapedEntity( $str )
249
+    public static function isADoubleEscapedEntity($str)
250 250
     {
251
-        return preg_match( self::$htmlEntityRegex, $str ) != 0;
251
+        return preg_match(self::$htmlEntityRegex, $str) != 0;
252 252
     }
253 253
 
254 254
     /**
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
      *
257 257
      * @return bool
258 258
      */
259
-    public static function isAnEscapedHTML( $str )
259
+    public static function isAnEscapedHTML($str)
260 260
     {
261
-        return preg_match( "/\/[a-z]*&gt;/i", $str ) != 0;
261
+        return preg_match("/\/[a-z]*&gt;/i", $str) != 0;
262 262
     }
263 263
 
264 264
     /**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
      *
267 267
      * @return bool
268 268
      */
269
-    public static function isAValidUuid( $uuid )
269
+    public static function isAValidUuid($uuid)
270 270
     {
271 271
         return preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/', $uuid) === 1;
272 272
     }
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
      */
280 280
     public static function preg_split($pattern, $subject)
281 281
     {
282
-        return preg_split( $pattern, $subject, -1, PREG_SPLIT_NO_EMPTY );
282
+        return preg_split($pattern, $subject, -1, PREG_SPLIT_NO_EMPTY);
283 283
     }
284 284
 
285 285
     /**
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
      *
333 333
      * @return mixed
334 334
      */
335
-    private static function recursiveIncrementNumberOfTrailingSpaces( $segment, &$number)
335
+    private static function recursiveIncrementNumberOfTrailingSpaces($segment, &$number)
336 336
     {
337
-        if(self::lastChar($segment) === ' '){
337
+        if (self::lastChar($segment) === ' ') {
338 338
             $number++;
339 339
             $segment = substr($segment, 0, -1);
340 340
 
@@ -354,11 +354,11 @@  discard block
 block discarded – undo
354 354
     {
355 355
         $string = stripslashes($string);
356 356
 
357
-        if($string === '<>'){
357
+        if ($string === '<>') {
358 358
             return false;
359 359
         }
360 360
 
361
-        preg_match("/<\/?[a-zA-Z1-6-]+((\s+[a-zA-Z1-6-]+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>/",$string, $matches);
361
+        preg_match("/<\/?[a-zA-Z1-6-]+((\s+[a-zA-Z1-6-]+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>/", $string, $matches);
362 362
 
363 363
         return count($matches) !== 0;
364 364
     }
Please login to merge, or discard this patch.
src/Utils/FlatData.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
     public static function flatArray(array $input = [], $separator_elements = ', ', $separator = ': ')
13 13
     {
14 14
         return implode($separator_elements, array_map(
15
-            function ($v, $k, $s) {
15
+            function($v, $k, $s) {
16 16
                 return sprintf("%s{$s}\"%s\"", $k, $v);
17 17
             },
18 18
             $input,
Please login to merge, or discard this patch.
src/Utils/HtmlParser.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 
54 54
         foreach ($matches[0] as $key => $match) {
55 55
 
56
-            $current = $matches[ 0 ][ $key ][ 0 ];
56
+            $current = $matches[0][$key][0];
57 57
 
58
-            if(isset($matches[0][$key+1][0])){
59
-                $next = $matches[0][$key+1][0];
60
-                $nextOffset = $matches[0][$key+1][1];
58
+            if (isset($matches[0][$key + 1][0])) {
59
+                $next = $matches[0][$key + 1][0];
60
+                $nextOffset = $matches[0][$key + 1][1];
61 61
                 $realNextOffset = ($delta === 0) ? $nextOffset : ($nextOffset + $delta);
62 62
             }
63 63
 
@@ -65,13 +65,13 @@  discard block
 block discarded – undo
65 65
             $offset = $matches[0][$key][1];
66 66
             $realOffset = ($delta === 0) ? $offset : ($offset + $delta);
67 67
 
68
-            if( $current === '<' and isset($next)){
68
+            if ($current === '<' and isset($next)) {
69 69
 
70 70
                 // 1. if next is > or
71 71
                 // 2. next is < and is not html tag (like < >)
72
-                $insideAngularTags = substr($html, $realOffset, ($realNextOffset-$realOffset+1));
72
+                $insideAngularTags = substr($html, $realOffset, ($realNextOffset - $realOffset + 1));
73 73
 
74
-                if($next !== '>' or !Strings::isHtmlString($insideAngularTags) ){
74
+                if ($next !== '>' or !Strings::isHtmlString($insideAngularTags)) {
75 75
                     $html = substr_replace($html, self::LT_PLACEHOLDER, $realOffset, $length);
76 76
                     $delta = $delta + strlen(self::LT_PLACEHOLDER) - $length;
77 77
                 }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      *
97 97
      * @return mixed
98 98
      */
99
-    private static function protectNotClosedHtmlTags( $html)
99
+    private static function protectNotClosedHtmlTags($html)
100 100
     {
101 101
         preg_match_all('/<|>/iu', $html, $matches, PREG_OFFSET_CAPTURE);
102 102
 
@@ -106,17 +106,17 @@  discard block
 block discarded – undo
106 106
 
107 107
         // 1. Map all tags
108 108
         foreach ($matches[0] as $key => $match) {
109
-            $current       = $matches[ 0 ][ $key ][ 0 ];
110
-            $currentOffset = $matches[ 0 ][ $key ][ 1 ];
109
+            $current       = $matches[0][$key][0];
110
+            $currentOffset = $matches[0][$key][1];
111 111
 
112 112
             // check every string inside angular brackets (< and >)
113
-            if( $current === '<' and isset($matches[0][$key+1][0]) and $matches[0][$key+1][0] === '>' ){
114
-                $nextOffset = $matches[0][$key+1][1];
115
-                $tag = substr($html, ($currentOffset + 1), ( $nextOffset - $currentOffset - 1 ));
113
+            if ($current === '<' and isset($matches[0][$key + 1][0]) and $matches[0][$key + 1][0] === '>') {
114
+                $nextOffset = $matches[0][$key + 1][1];
115
+                $tag = substr($html, ($currentOffset + 1), ($nextOffset - $currentOffset - 1));
116 116
                 $trimmedTag = trim($tag);
117 117
 
118 118
                 // if the tag is self closed do nothing
119
-                if(Strings::lastChar($tag) !== '/'){
119
+                if (Strings::lastChar($tag) !== '/') {
120 120
                     $tags[] = $trimmedTag;
121 121
                     $offsets[] = $currentOffset;
122 122
                     $originalLengths[] = strlen($tag) + 2; // add 2 to length because there are < and >
@@ -127,18 +127,18 @@  discard block
 block discarded – undo
127 127
         // 2. Removing closed tags
128 128
         $indexes = [];
129 129
 
130
-        if(count($tags) > 0){
131
-            foreach ($tags as $index => $tag){
130
+        if (count($tags) > 0) {
131
+            foreach ($tags as $index => $tag) {
132 132
 
133
-                if(Strings::contains('/', $tag)){
133
+                if (Strings::contains('/', $tag)) {
134 134
                     $complementaryTag = $tag;
135 135
                 } else {
136
-                    $complementaryTag = '/'.explode(' ', $tag)[0];
136
+                    $complementaryTag = '/' . explode(' ', $tag)[0];
137 137
                 }
138 138
 
139 139
                 $complementaryTagIndex = array_search($complementaryTag, $tags);
140 140
 
141
-                if(false !== $complementaryTagIndex){
141
+                if (false !== $complementaryTagIndex) {
142 142
                     $indexes[] = $index;
143 143
                     $indexes[] = $complementaryTagIndex;
144 144
                 }
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
         }
147 147
 
148 148
         $indexes = array_unique($indexes);
149
-        foreach ($indexes as $index){
149
+        foreach ($indexes as $index) {
150 150
             unset($tags[$index]);
151 151
         }
152 152
 
153 153
         // 3. Loop not closed tags
154 154
         $delta = 0;
155 155
 
156
-        if(count($tags)){
157
-            foreach ($tags as $index => $tag){
156
+        if (count($tags)) {
157
+            foreach ($tags as $index => $tag) {
158 158
 
159 159
                 $length = $originalLengths[$index];
160 160
                 $offset = $offsets[$index];
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
      *
177 177
      * @return array
178 178
      */
179
-    private static function extractHtmlNode( $html, $toBeEscaped = false)
179
+    private static function extractHtmlNode($html, $toBeEscaped = false)
180 180
     {
181
-        $pattern = "/<([a-zA-Z0-9._-]+)([^>]|[^<]*?)(([\s]*\/>)|".
181
+        $pattern = "/<([a-zA-Z0-9._-]+)([^>]|[^<]*?)(([\s]*\/>)|" .
182 182
                 "(>((([^<]*?|<\!\-\-.*?\-\->)|(?R))*)<\/\\1[\s]*>))/sm";
183 183
         preg_match_all($pattern, $html, $matches, PREG_OFFSET_CAPTURE);
184 184
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         foreach ($matches[0] as $key => $match) {
188 188
 
189 189
             $attributes = isset($matches[2][$key][0]) ? self::getAttributes($matches[2][$key][0]) : [];
190
-            $base64Decoded = (isset($attributes['equiv-text'])) ? base64_decode(str_replace("base64:", "", $attributes['equiv-text'])): null;
190
+            $base64Decoded = (isset($attributes['equiv-text'])) ? base64_decode(str_replace("base64:", "", $attributes['equiv-text'])) : null;
191 191
             $tagName = $matches[1][$key][0];
192 192
             $text = (isset($matches[6][$key][0]) and '' !== $matches[6][$key][0]) ? $matches[6][$key][0] : null;
193 193
             $originalText = $text;
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
      *
238 238
      * @return string|string[]
239 239
      */
240
-    private static function restoreLessThanAndGreaterThanSymbols( $text)
240
+    private static function restoreLessThanAndGreaterThanSymbols($text)
241 241
     {
242
-        return str_replace([self::LT_PLACEHOLDER, self::GT_PLACEHOLDER], ['<','>'], $text);
242
+        return str_replace([self::LT_PLACEHOLDER, self::GT_PLACEHOLDER], ['<', '>'], $text);
243 243
     }
244 244
 
245 245
     /**
@@ -254,13 +254,13 @@  discard block
 block discarded – undo
254 254
     {
255 255
         $node = '';
256 256
 
257
-        if($start !== null){
257
+        if ($start !== null) {
258 258
             $node .= ($toBeEscaped) ? Strings::escapeOnlyHTMLTags($start) : $start;
259 259
         }
260 260
 
261 261
         $node .= ($toBeEscaped) ? Strings::escapeOnlyHTMLTags($originalText) : $originalText;
262 262
 
263
-        if($end !== null){
263
+        if ($end !== null) {
264 264
             $node .= ($toBeEscaped) ? Strings::escapeOnlyHTMLTags($end) : $end;
265 265
         }
266 266
 
Please login to merge, or discard this patch.