Passed
Push — master ( d475ac...015c9a )
by Once
02:08
created
src/Support.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
     {
23 23
         $n = $columnNumber;
24 24
         for ($r = ''; $n >= 0; $n = intval($n / 26) - 1) {
25
-            $r = chr($n % 26 + 0x41).$r;
25
+            $r = chr($n % 26 + 0x41) . $r;
26 26
         }
27 27
         if ($absolute) {
28
-            return '$'.$r.'$'.($rowNumber + 1);
28
+            return '$' . $r . '$' . ($rowNumber + 1);
29 29
         }
30 30
 
31
-        return $r.($rowNumber + 1);
31
+        return $r . ($rowNumber + 1);
32 32
     }
33 33
 
34 34
     /**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
                 $ignoreUntil = '';
83 83
             }
84 84
             if ('' == $ignoreUntil && (' ' == $c || '-' == $c || '(' == $c || ')' == $c) && (0 == $i || '_' != $numFormat[$i - 1])) {
85
-                $escaped .= '\\'.$c;
85
+                $escaped .= '\\' . $c;
86 86
             } else {
87 87
                 $escaped .= $c;
88 88
             }
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public static function convertDateTime($dateInput)
158 158
     {
159
-        $seconds = 0;    // Time expressed as fraction of 24h hours in seconds
160
-        $year    = $month    = $day    = 0;
159
+        $seconds = 0; // Time expressed as fraction of 24h hours in seconds
160
+        $year    = $month = $day = 0;
161 161
 
162 162
         $date_time = $dateInput;
163 163
         if (preg_match("/(\d{4})\-(\d{2})\-(\d{2})/", $date_time, $matches)) {
@@ -202,13 +202,13 @@  discard block
 block discarded – undo
202 202
             return 0;
203 203
         }
204 204
         // Accumulate the number of days since the epoch.
205
-        $days = $day;    // Add days for current month
206
-        $days += array_sum(array_slice($mdays, 0, $month - 1));    // Add days for past months
207
-        $days += $range * 365;                      // Add days for past years
208
-        $days += intval(($range) / 4);             // Add leapdays
205
+        $days = $day; // Add days for current month
206
+        $days += array_sum(array_slice($mdays, 0, $month - 1)); // Add days for past months
207
+        $days += $range * 365; // Add days for past years
208
+        $days += intval(($range) / 4); // Add leapdays
209 209
         $days -= intval(($range + $offset) / 100); // Subtract 100 year leapdays
210
-        $days += intval(($range + $offset + $norm) / 400);  // Add 400 year leapdays
211
-        $days -= $leap;                                      // Already counted above
210
+        $days += intval(($range + $offset + $norm) / 400); // Add 400 year leapdays
211
+        $days -= $leap; // Already counted above
212 212
         // Adjust for Excel erroneously treating 1900 as a leap year.
213 213
         if ($days > 59) {
214 214
             ++$days;
@@ -225,6 +225,6 @@  discard block
 block discarded – undo
225 225
         $sheetname        = mb_substr($sheetname, 0, 31);
226 226
         $sheetname        = trim(trim(trim($sheetname), "'")); //trim before and after trimming single quotes
227 227
 
228
-        return !empty($sheetname) ? $sheetname : 'Sheet'.((rand() % 900) + 100);
228
+        return !empty($sheetname) ? $sheetname : 'Sheet' . ((rand() % 900) + 100);
229 229
     }
230 230
 }
Please login to merge, or discard this patch.
src/Writer/XlsxBuilder.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
         $author   = Support::xmlSpecialChars($author);
47 47
         $keywords = Support::xmlSpecialChars(implode(',', $keywords));
48 48
         if ($keywords) {
49
-            $keywords = '<cp:keywords>'.$keywords.'</cp:keywords>';
49
+            $keywords = '<cp:keywords>' . $keywords . '</cp:keywords>';
50 50
         }
51 51
         $description = Support::xmlSpecialChars($description);
52 52
         $date        = date("Y-m-d\TH:i:s.00\Z");
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     public static function buildRelationshipsXML()
68 68
     {
69 69
         $relsXml = '';
70
-        $relsXml .= '<?xml version="1.0" encoding="UTF-8"?>'."\n";
70
+        $relsXml .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
71 71
         $relsXml .= '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">';
72 72
         $relsXml .= '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>';
73 73
         $relsXml .= '<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>';
@@ -92,17 +92,17 @@  discard block
 block discarded – undo
92 92
 EOF;
93 93
         foreach ($sheets as $sheetName => $sheet) {
94 94
             $sheetname = Support::sanitizeSheetname($sheet->sheetname);
95
-            $workbookXml .= '<sheet name="'.Support::xmlSpecialChars($sheetname).
96
-                '" sheetId="'.($i + 1).'" state="visible" r:id="rId'.($i + 2).'"/>';
95
+            $workbookXml .= '<sheet name="' . Support::xmlSpecialChars($sheetname) .
96
+                '" sheetId="' . ($i + 1) . '" state="visible" r:id="rId' . ($i + 2) . '"/>';
97 97
             ++$i;
98 98
         }
99 99
         $workbookXml .= '</sheets><definedNames>';
100 100
         foreach ($sheets as $sheetName => $sheet) {
101 101
             if ($sheet->autoFilter) {
102 102
                 $sheetname = Support::sanitizeSheetname($sheet->sheetname);
103
-                $workbookXml .= '<definedName name="_xlnm._FilterDatabase" localSheetId="0" hidden="1">\''.
104
-                    Support::xmlSpecialChars($sheetname).'\'!$A$1:'.
105
-                    Support::xlsCell($sheet->rowCount - 1, count($sheet->columns) - 1, true).'</definedName>';
103
+                $workbookXml .= '<definedName name="_xlnm._FilterDatabase" localSheetId="0" hidden="1">\'' .
104
+                    Support::xmlSpecialChars($sheetname) . '\'!$A$1:' .
105
+                    Support::xlsCell($sheet->rowCount - 1, count($sheet->columns) - 1, true) . '</definedName>';
106 106
                 ++$i;
107 107
             }
108 108
         }
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>
125 125
 EOF;
126 126
         foreach ($sheets as $sheetName => $sheet) {
127
-            $wkbkrelsXml .= '<Relationship Id="rId'.($i + 2).
128
-                '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/'.
129
-                ($sheet->xmlname).'"/>';
127
+            $wkbkrelsXml .= '<Relationship Id="rId' . ($i + 2) .
128
+                '" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/' .
129
+                ($sheet->xmlname) . '"/>';
130 130
             ++$i;
131 131
         }
132
-        $wkbkrelsXml .= "\n".'</Relationships>';
132
+        $wkbkrelsXml .= "\n" . '</Relationships>';
133 133
 
134 134
         return $wkbkrelsXml;
135 135
     }
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
     public static function buildContentTypesXML(array $sheets)
143 143
     {
144 144
         $contentTypesXml = '';
145
-        $contentTypesXml .= '<?xml version="1.0" encoding="UTF-8"?>'."\n";
145
+        $contentTypesXml .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
146 146
         $contentTypesXml .= '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
147 147
         $contentTypesXml .= '<Override PartName="/_rels/.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>';
148 148
         $contentTypesXml .= '<Override PartName="/xl/_rels/workbook.xml.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>';
149 149
         foreach ($sheets as $sheetName => $sheet) {
150
-            $contentTypesXml .= '<Override PartName="/xl/worksheets/'.($sheet->xmlname).'" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>';
150
+            $contentTypesXml .= '<Override PartName="/xl/worksheets/' . ($sheet->xmlname) . '" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>';
151 151
         }
152 152
         $contentTypesXml .= '<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>';
153 153
         $contentTypesXml .= '<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>';
Please login to merge, or discard this patch.
src/Writer/Builder.php 1 patch
Spacing   +32 added lines, -34 removed lines patch added patch discarded remove patch
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
             if (is_writable($filename)) {
156 156
                 @unlink($filename); //if the zip already exists, remove it
157 157
             } else {
158
-                throw new XlsxException('Error in '.__CLASS__.'::'.__FUNCTION__.', file is not writeable.');
158
+                throw new XlsxException('Error in ' . __CLASS__ . '::' . __FUNCTION__ . ', file is not writeable.');
159 159
             }
160 160
         }
161 161
         $zip = new \ZipArchive();
162 162
         if (empty($this->sheets)) {
163
-            throw new XlsxException('Error in '.__CLASS__.'::'.__FUNCTION__.', no worksheets defined.');
163
+            throw new XlsxException('Error in ' . __CLASS__ . '::' . __FUNCTION__ . ', no worksheets defined.');
164 164
         }
165 165
         if (!$zip->open($filename, \ZipArchive::CREATE)) {
166
-            throw new XlsxException('Error in '.__CLASS__.'::'.__FUNCTION__.', unable to create zip.');
166
+            throw new XlsxException('Error in ' . __CLASS__ . '::' . __FUNCTION__ . ', unable to create zip.');
167 167
         }
168 168
         $zip->addEmptyDir('docProps/');
169 169
         $zip->addFromString('docProps/app.xml', XlsxBuilder::buildAppXML($this->company));
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
         $zip->addFromString('_rels/.rels', XlsxBuilder::buildRelationshipsXML());
179 179
         $zip->addEmptyDir('xl/worksheets/');
180 180
         foreach ($this->sheets as $sheet) {
181
-            $zip->addFile($sheet->filename, 'xl/worksheets/'.$sheet->xmlname);
181
+            $zip->addFile($sheet->filename, 'xl/worksheets/' . $sheet->xmlname);
182 182
         }
183 183
         $zip->addFromString('xl/workbook.xml', XlsxBuilder::buildWorkbookXML($this->sheets));
184
-        $zip->addFile($this->writeStylesXML(), 'xl/styles.xml');  //$zip->addFromString("xl/styles.xml", self::buildStylesXML() );
184
+        $zip->addFile($this->writeStylesXML(), 'xl/styles.xml'); //$zip->addFromString("xl/styles.xml", self::buildStylesXML() );
185 185
         $zip->addFromString('[Content_Types].xml', XlsxBuilder::buildContentTypesXML($this->sheets));
186 186
         $zip->addEmptyDir('xl/_rels/');
187 187
         $zip->addFromString('xl/_rels/workbook.xml.rels', XlsxBuilder::buildWorkbookRelsXML($this->sheets));
@@ -204,22 +204,22 @@  discard block
 block discarded – undo
204 204
         $sheet = $this->getSheet();
205 205
         if (count($sheet->columns) < count($row)) {
206 206
             $defaultColumnTypes = $this->initColumnsTypes(array_fill($from = 0, count($row), 'GENERAL')); //will map to n_auto
207
-            $sheet->columns     = array_merge((array) $sheet->columns, $defaultColumnTypes);
207
+            $sheet->columns     = array_merge((array)$sheet->columns, $defaultColumnTypes);
208 208
         }
209 209
 
210 210
         if (!empty($rowOptions)) {
211 211
             $ht        = isset($rowOptions['height']) ? floatval($rowOptions['height']) : 12.1;
212 212
             $customHt  = isset($rowOptions['height']) ? true : false;
213
-            $hidden    = isset($rowOptions['hidden']) ? (bool) ($rowOptions['hidden']) : false;
214
-            $collapsed = isset($rowOptions['collapsed']) ? (bool) ($rowOptions['collapsed']) : false;
213
+            $hidden    = isset($rowOptions['hidden']) ? (bool)($rowOptions['hidden']) : false;
214
+            $collapsed = isset($rowOptions['collapsed']) ? (bool)($rowOptions['collapsed']) : false;
215 215
             $sheet->fileWriter->write(
216
-                '<row collapsed="'.($collapsed).'" customFormat="false" customHeight="'.($customHt).
217
-                '" hidden="'.($hidden).'" ht="'.($ht).'" outlineLevel="0" r="'.($sheet->rowCount + 1).'">'
216
+                '<row collapsed="' . ($collapsed) . '" customFormat="false" customHeight="' . ($customHt) .
217
+                '" hidden="' . ($hidden) . '" ht="' . ($ht) . '" outlineLevel="0" r="' . ($sheet->rowCount + 1) . '">'
218 218
             );
219 219
         } else {
220 220
             $sheet->fileWriter->write(
221
-                '<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="'.
222
-                ($sheet->rowCount + 1).'">'
221
+                '<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' .
222
+                ($sheet->rowCount + 1) . '">'
223 223
             );
224 224
         }
225 225
 
@@ -228,8 +228,7 @@  discard block
 block discarded – undo
228 228
         foreach ($row as $v) {
229 229
             $numberFormat     = $sheet->columns[$c]['number_format'];
230 230
             $numberFormatType = $sheet->columns[$c]['number_format_type'];
231
-            $cellStyleIdx     = empty($style) ? $sheet->columns[$c]['default_cell_style'] :
232
-                $this->addCellStyle($numberFormat, json_encode(isset($style[0]) ? $style[$c] : $style));
231
+            $cellStyleIdx     = empty($style) ? $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle($numberFormat, json_encode(isset($style[0]) ? $style[$c] : $style));
233 232
             $sheet->writeCell($sheet->rowCount, $c, $v, $numberFormatType, $cellStyleIdx);
234 233
             ++$c;
235 234
         }
@@ -265,14 +264,14 @@  discard block
 block discarded – undo
265 264
 
266 265
         $temporaryFilename = $this->tempFilename();
267 266
         $file              = new XlsxWriterBuffer($temporaryFilename);
268
-        $file->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n");
267
+        $file->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n");
269 268
         $file->write('<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">');
270
-        $file->write('<numFmts count="'.count($this->numberFormats).'">');
269
+        $file->write('<numFmts count="' . count($this->numberFormats) . '">');
271 270
         foreach ($this->numberFormats as $i => $v) {
272
-            $file->write('<numFmt numFmtId="'.(164 + $i).'" formatCode="'.Support::xmlSpecialChars($v).'" />');
271
+            $file->write('<numFmt numFmtId="' . (164 + $i) . '" formatCode="' . Support::xmlSpecialChars($v) . '" />');
273 272
         }
274 273
         $file->write('</numFmts>');
275
-        $file->write('<fonts count="'.(count($fonts)).'">');
274
+        $file->write('<fonts count="' . (count($fonts)) . '">');
276 275
         $file->write('<font><name val="Arial"/><charset val="1"/><family val="2"/><sz val="10"/></font>');
277 276
         $file->write('<font><name val="Arial"/><family val="0"/><sz val="10"/></font>');
278 277
         $file->write('<font><name val="Arial"/><family val="0"/><sz val="10"/></font>');
@@ -282,10 +281,10 @@  discard block
 block discarded – undo
282 281
             if (!empty($font)) { //fonts have 4 empty placeholders in array to offset the 4 static xml entries above
283 282
                 $f = json_decode($font, true);
284 283
                 $file->write('<font>');
285
-                $file->write('<name val="'.htmlspecialchars($f['name']).'"/><charset val="1"/><family val="'.intval($f['family']).'"/>');
286
-                $file->write('<sz val="'.intval($f['size']).'"/>');
284
+                $file->write('<name val="' . htmlspecialchars($f['name']) . '"/><charset val="1"/><family val="' . intval($f['family']) . '"/>');
285
+                $file->write('<sz val="' . intval($f['size']) . '"/>');
287 286
                 if (!empty($f['color'])) {
288
-                    $file->write('<color rgb="'.strval($f['color']).'"/>');
287
+                    $file->write('<color rgb="' . strval($f['color']) . '"/>');
289 288
                 }
290 289
                 if (!empty($f['bold'])) {
291 290
                     $file->write('<b val="true"/>');
@@ -304,23 +303,23 @@  discard block
 block discarded – undo
304 303
         }
305 304
         $file->write('</fonts>');
306 305
 
307
-        $file->write('<fills count="'.(count($fills)).'">');
306
+        $file->write('<fills count="' . (count($fills)) . '">');
308 307
         $file->write('<fill><patternFill patternType="none"/></fill>');
309 308
         $file->write('<fill><patternFill patternType="gray125"/></fill>');
310 309
         foreach ($fills as $fill) {
311 310
             if (!empty($fill)) { //fills have 2 empty placeholders in array to offset the 2 static xml entries above
312
-                $file->write('<fill><patternFill patternType="solid"><fgColor rgb="'.strval($fill).'"/><bgColor indexed="64"/></patternFill></fill>');
311
+                $file->write('<fill><patternFill patternType="solid"><fgColor rgb="' . strval($fill) . '"/><bgColor indexed="64"/></patternFill></fill>');
313 312
             }
314 313
         }
315 314
         $file->write('</fills>');
316 315
 
317
-        $file->write('<borders count="'.(count($borders)).'">');
316
+        $file->write('<borders count="' . (count($borders)) . '">');
318 317
         $file->write('<border diagonalDown="false" diagonalUp="false"><left/><right/><top/><bottom/><diagonal/></border>');
319 318
         foreach ($borders as $border) {
320 319
             if (!empty($border)) { //fonts have an empty placeholder in the array to offset the static xml entry above
321 320
                 $pieces       = json_decode($border, true);
322 321
                 $border_style = !empty($pieces['style']) ? $pieces['style'] : 'hair';
323
-                $border_color = !empty($pieces['color']) ? '<color rgb="'.strval($pieces['color']).'"/>' : '';
322
+                $border_color = !empty($pieces['color']) ? '<color rgb="' . strval($pieces['color']) . '"/>' : '';
324 323
                 $file->write('<border diagonalDown="false" diagonalUp="false">');
325 324
                 foreach (['left', 'right', 'top', 'bottom'] as $side) {
326 325
                     $show_side = in_array($side, $pieces['side']) ? true : false;
@@ -358,7 +357,7 @@  discard block
 block discarded – undo
358 357
         $file->write('<xf applyAlignment="false" applyBorder="false" applyFont="true" applyProtection="false" borderId="0" fillId="0" fontId="1" numFmtId="9"/>');
359 358
         $file->write('</cellStyleXfs>');
360 359
 
361
-        $file->write('<cellXfs count="'.(count($styleIndexes)).'">');
360
+        $file->write('<cellXfs count="' . (count($styleIndexes)) . '">');
362 361
         foreach ($styleIndexes as $v) {
363 362
             $applyAlignment = isset($v['alignment']) ? 'true' : 'false';
364 363
             $wrapText       = !empty($v['wrap_text']) ? 'true' : 'false';
@@ -369,8 +368,8 @@  discard block
 block discarded – undo
369 368
             $borderIdx      = isset($v['border_idx']) ? intval($v['border_idx']) : 0;
370 369
             $fillIdx        = isset($v['fill_idx']) ? intval($v['fill_idx']) : 0;
371 370
             $fontIdx        = isset($v['font_idx']) ? intval($v['font_idx']) : 0;
372
-            $file->write('<xf applyAlignment="'.$applyAlignment.'" applyBorder="'.$applyBorder.'" applyFont="'.$applyFont.'" applyProtection="false" borderId="'.($borderIdx).'" fillId="'.($fillIdx).'" fontId="'.($fontIdx).'" numFmtId="'.(164 + $v['num_fmt_idx']).'" xfId="0">');
373
-            $file->write('	<alignment horizontal="'.$horizAlignment.'" vertical="'.$vertAlignment.'" textRotation="0" wrapText="'.$wrapText.'" indent="0" shrinkToFit="false"/>');
371
+            $file->write('<xf applyAlignment="' . $applyAlignment . '" applyBorder="' . $applyBorder . '" applyFont="' . $applyFont . '" applyProtection="false" borderId="' . ($borderIdx) . '" fillId="' . ($fillIdx) . '" fontId="' . ($fontIdx) . '" numFmtId="' . (164 + $v['num_fmt_idx']) . '" xfId="0">');
372
+            $file->write('	<alignment horizontal="' . $horizAlignment . '" vertical="' . $vertAlignment . '" textRotation="0" wrapText="' . $wrapText . '" indent="0" shrinkToFit="false"/>');
374 373
             $file->write('	<protection locked="true" hidden="false"/>');
375 374
             $file->write('</xf>');
376 375
         }
@@ -413,7 +412,7 @@  discard block
 block discarded – undo
413 412
         if ($this->sheetName == $sheetName || $this->hasSheet($sheetName)) {
414 413
             return;
415 414
         }
416
-        $colWidths = isset($colOptions['widths']) ? (array) $colOptions['widths'] : [];
415
+        $colWidths = isset($colOptions['widths']) ? (array)$colOptions['widths'] : [];
417 416
         $this->createSheet($sheetName, $colOptions);
418 417
         $sheet = $this->getSheet();
419 418
         $sheet->initContent($colWidths, $this->isTabSelected());
@@ -422,12 +421,11 @@  discard block
 block discarded – undo
422 421
             $headerRow      = array_keys($headerTypes);
423 422
             $writer         = $sheet->getFileWriter();
424 423
             $writer->write(
425
-                '<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="'. 1 .'">'
424
+                '<row collapsed="false" customFormat="false" customHeight="false" hidden="false" ht="12.1" outlineLevel="0" r="' . 1 . '">'
426 425
             );
427 426
             foreach ($headerRow as $c => $v) {
428 427
                 $cellStyleIdx = empty($style) ?
429
-                    $sheet->columns[$c]['default_cell_style'] :
430
-                    $this->addCellStyle('GENERAL', json_encode(isset($style[0]) ? $style[$c] : $style));
428
+                    $sheet->columns[$c]['default_cell_style'] : $this->addCellStyle('GENERAL', json_encode(isset($style[0]) ? $style[$c] : $style));
431 429
                 $sheet->writeCell(0, $c, $v, 'n_string', $cellStyleIdx);
432 430
             }
433 431
             $writer->write('</row>');
@@ -441,7 +439,7 @@  discard block
 block discarded – undo
441 439
             $numberFormat = Support::numberFormatStandardized($v);
442 440
             $cellStyleIdx = $this->addCellStyle($numberFormat, $styleString = null);
443 441
             $columns[]    = [
444
-                'number_format'      => $numberFormat,      //contains excel format like 'YYYY-MM-DD HH:MM:SS'
442
+                'number_format'      => $numberFormat, //contains excel format like 'YYYY-MM-DD HH:MM:SS'
445 443
                 'number_format_type' => Support::determineNumberFormatType($numberFormat), //contains friendly format like 'datetime'
446 444
                 'default_cell_style' => $cellStyleIdx,
447 445
             ];
@@ -497,7 +495,7 @@  discard block
 block discarded – undo
497 495
     protected function createSheet(string $sheetName, array $colOptions = [])
498 496
     {
499 497
         $sheetFilename = $this->tempFilename();
500
-        $sheetXmlName  = 'sheet'.(count($this->sheets) + 1).'.xml';
498
+        $sheetXmlName  = 'sheet' . (count($this->sheets) + 1) . '.xml';
501 499
         $autoFilter    = isset($colOptions['auto_filter']) ? intval($colOptions['auto_filter']) : false;
502 500
         $freezeRows    = isset($colOptions['freeze_rows']) ? intval($colOptions['freeze_rows']) : false;
503 501
         $freezeColumns = isset($colOptions['freeze_columns']) ? intval($colOptions['freeze_columns']) : false;
Please login to merge, or discard this patch.
src/Writer/Sheet.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -64,39 +64,39 @@  discard block
 block discarded – undo
64 64
         $cellName = Support::xlsCell($rowNumber, $columnNumber);
65 65
         $file     = $this->getFileWriter();
66 66
         if (!is_scalar($value) || '' === $value) { //objects, array, empty
67
-            $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'"/>');
67
+            $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '"/>');
68 68
         } elseif (is_string($value) && '=' == $value[0]) {
69
-            $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="s"><f>'.Support::xmlSpecialChars($value).'</f></c>');
69
+            $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="s"><f>' . Support::xmlSpecialChars($value) . '</f></c>');
70 70
         } else {
71 71
             switch ($numFormatType) {
72 72
                 case 'n_date':
73
-                    $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'.
74
-                        intval(Support::convertDateTime($value)).'</v></c>');
73
+                    $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' .
74
+                        intval(Support::convertDateTime($value)) . '</v></c>');
75 75
                     break;
76 76
                 case 'n_datetime':
77
-                    $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'.
78
-                        Support::convertDateTime($value).'</v></c>');
77
+                    $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' .
78
+                        Support::convertDateTime($value) . '</v></c>');
79 79
                     break;
80 80
                 case 'n_numeric':
81
-                    $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'.
82
-                        Support::xmlSpecialChars($value).'</v></c>'); //int,float,currency
81
+                    $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' .
82
+                        Support::xmlSpecialChars($value) . '</v></c>'); //int,float,currency
83 83
                     break;
84 84
                 case 'n_string':
85
-                    $file->write('<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="inlineStr"><is><t>'.
86
-                        Support::xmlSpecialChars($value).'</t></is></c>');
85
+                    $file->write('<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="inlineStr"><is><t>' .
86
+                        Support::xmlSpecialChars($value) . '</t></is></c>');
87 87
                     break;
88 88
                 case 'n_auto':
89 89
                 default: //auto-detect unknown column types
90 90
                     if (!is_string($value) || '0' == $value || ('0' != $value[0] && ctype_digit($value)) || preg_match("/^\-?(0|[1-9][0-9]*)(\.[0-9]+)?$/", $value)
91 91
                     ) { //int,float,currency
92 92
                         $file->write(
93
-                            '<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="n"><v>'.
94
-                            Support::xmlSpecialChars($value).'</v></c>'
93
+                            '<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="n"><v>' .
94
+                            Support::xmlSpecialChars($value) . '</v></c>'
95 95
                         );
96 96
                     } else { //implied: ($cell_format=='string')
97 97
                         $file->write(
98
-                            '<c r="'.$cellName.'" s="'.$cellStyleIdx.'" t="inlineStr"><is><t>'.
99
-                            Support::xmlSpecialChars($value).'</t></is></c>'
98
+                            '<c r="' . $cellName . '" s="' . $cellStyleIdx . '" t="inlineStr"><is><t>' .
99
+                            Support::xmlSpecialChars($value) . '</t></is></c>'
100 100
                         );
101 101
                     }
102 102
                     break;
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
         $writer      = $this->getFileWriter();
114 114
         $tabSelected = $isTabSelected ? 'true' : 'false';
115 115
         $maxCell     = Support::xlsCell(XlsxWriter::EXCEL_2007_MAX_ROW, XlsxWriter::EXCEL_2007_MAX_COL); //XFE1048577
116
-        $writer->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'."\n");
116
+        $writer->write('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>' . "\n");
117 117
         $writer->write(
118 118
             <<<EOF
119 119
 <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheetPr filterMode="false"><pageSetUpPr fitToPage="false"/></sheetPr>
120 120
 EOF
121 121
         );
122 122
         $this->maxCellTagStart = $this->fileWriter->ftell();
123
-        $writer->write('<dimension ref="A1:'.$maxCell.'"/>');
123
+        $writer->write('<dimension ref="A1:' . $maxCell . '"/>');
124 124
         $this->maxCellTagEnd = $this->fileWriter->ftell();
125 125
         $writer->write('<sheetViews>');
126 126
         $writer->write(
@@ -142,15 +142,15 @@  discard block
 block discarded – undo
142 142
         if (!empty($colWidths)) {
143 143
             foreach ($colWidths as $colWidth) {
144 144
                 $writer->write(
145
-                    '<col collapsed="false" hidden="false" max="'.($i + 1).'" min="'.($i + 1).
146
-                    '" style="0" customWidth="true" width="'.floatval($colWidth).'"/>'
145
+                    '<col collapsed="false" hidden="false" max="' . ($i + 1) . '" min="' . ($i + 1) .
146
+                    '" style="0" customWidth="true" width="' . floatval($colWidth) . '"/>'
147 147
                 );
148 148
                 ++$i;
149 149
             }
150 150
         }
151 151
         $writer->write(
152
-            '<col collapsed="false" hidden="false" max="1024" min="'.($i + 1).
153
-            '" style="0" customWidth="false" width="11.5"/>'.'</cols><sheetData>'
152
+            '<col collapsed="false" hidden="false" max="1024" min="' . ($i + 1) .
153
+            '" style="0" customWidth="false" width="11.5"/>' . '</cols><sheetData>'
154 154
         );
155 155
     }
156 156
 
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
         if (!empty($this->merge_cells)) {
162 162
             $this->fileWriter->write('<mergeCells>');
163 163
             foreach ($this->merge_cells as $range) {
164
-                $this->fileWriter->write('<mergeCell ref="'.$range.'"/>');
164
+                $this->fileWriter->write('<mergeCell ref="' . $range . '"/>');
165 165
             }
166 166
             $this->fileWriter->write('</mergeCells>');
167 167
         }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
         $max_cell = Support::xlsCell($this->rowCount - 1, count($this->columns) - 1);
170 170
 
171 171
         if ($this->autoFilter) {
172
-            $this->fileWriter->write('<autoFilter ref="A1:'.$max_cell.'"/>');
172
+            $this->fileWriter->write('<autoFilter ref="A1:' . $max_cell . '"/>');
173 173
         }
174 174
 
175 175
         $this->fileWriter->write('<printOptions headings="false" gridLines="false" gridLinesSet="true" horizontalCentered="false" verticalCentered="false"/>');
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
         $this->fileWriter->write('</headerFooter>');
182 182
         $this->fileWriter->write('</worksheet>');
183 183
 
184
-        $max_cell_tag   = '<dimension ref="A1:'.$max_cell.'"/>';
184
+        $max_cell_tag   = '<dimension ref="A1:' . $max_cell . '"/>';
185 185
         $padding_length = $this->maxCellTagEnd - $this->maxCellTagStart - strlen($max_cell_tag);
186 186
         $this->fileWriter->fseek($this->maxCellTagStart);
187
-        $this->fileWriter->write($max_cell_tag.str_repeat(' ', $padding_length));
187
+        $this->fileWriter->write($max_cell_tag . str_repeat(' ', $padding_length));
188 188
         $this->fileWriter->close();
189 189
         $this->finalized = true;
190 190
     }
@@ -193,14 +193,14 @@  discard block
 block discarded – undo
193 193
     {
194 194
         $writer = $this->getFileWriter();
195 195
         $writer->write(
196
-            '<pane ySplit="'.$this->freezeRows.'" xSplit="'.$this->freezeColumns.
197
-            '" topLeftCell="'.Support::xlsCell($this->freezeRows, $this->freezeColumns).
198
-            '" activePane="bottomRight" state="frozen"/>'.'<selection activeCell="'.Support::xlsCell($this->freezeRows, 0).
199
-            '" activeCellId="0" pane="topRight" sqref="'.Support::xlsCell($this->freezeRows, 0).'"/>'.
200
-            '<selection activeCell="'.Support::xlsCell(0, $this->freezeColumns).
201
-            '" activeCellId="0" pane="bottomLeft" sqref="'.Support::xlsCell(0, $this->freezeColumns).'"/>'.
202
-            '<selection activeCell="'.Support::xlsCell($this->freezeRows, $this->freezeColumns).
203
-            '" activeCellId="0" pane="bottomRight" sqref="'.Support::xlsCell($this->freezeRows, $this->freezeColumns).'"/>'
196
+            '<pane ySplit="' . $this->freezeRows . '" xSplit="' . $this->freezeColumns .
197
+            '" topLeftCell="' . Support::xlsCell($this->freezeRows, $this->freezeColumns) .
198
+            '" activePane="bottomRight" state="frozen"/>' . '<selection activeCell="' . Support::xlsCell($this->freezeRows, 0) .
199
+            '" activeCellId="0" pane="topRight" sqref="' . Support::xlsCell($this->freezeRows, 0) . '"/>' .
200
+            '<selection activeCell="' . Support::xlsCell(0, $this->freezeColumns) .
201
+            '" activeCellId="0" pane="bottomLeft" sqref="' . Support::xlsCell(0, $this->freezeColumns) . '"/>' .
202
+            '<selection activeCell="' . Support::xlsCell($this->freezeRows, $this->freezeColumns) .
203
+            '" activeCellId="0" pane="bottomRight" sqref="' . Support::xlsCell($this->freezeRows, $this->freezeColumns) . '"/>'
204 204
         );
205 205
     }
206 206
 
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
     {
209 209
         $writer = $this->getFileWriter();
210 210
         $writer->write(
211
-            '<pane ySplit="'.$this->freezeRows.'" topLeftCell="'.
212
-            Support::xlsCell($this->freezeRows, 0).'" activePane="bottomLeft" state="frozen"/>'.
213
-            '<selection activeCell="'.Support::xlsCell($this->freezeRows, 0).
214
-            '" activeCellId="0" pane="bottomLeft" sqref="'.Support::xlsCell($this->freezeRows, 0).'"/>'
211
+            '<pane ySplit="' . $this->freezeRows . '" topLeftCell="' .
212
+            Support::xlsCell($this->freezeRows, 0) . '" activePane="bottomLeft" state="frozen"/>' .
213
+            '<selection activeCell="' . Support::xlsCell($this->freezeRows, 0) .
214
+            '" activeCellId="0" pane="bottomLeft" sqref="' . Support::xlsCell($this->freezeRows, 0) . '"/>'
215 215
         );
216 216
     }
217 217
 
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
     {
220 220
         $writer = $this->getFileWriter();
221 221
         $writer->write(
222
-            '<pane xSplit="'.$this->freezeColumns.'" topLeftCell="'.
223
-            Support::xlsCell(0, $this->freezeColumns).'" activePane="topRight" state="frozen"/>'.
224
-            '<selection activeCell="'.Support::xlsCell(0, $this->freezeColumns).
225
-            '" activeCellId="0" pane="topRight" sqref="'.Support::xlsCell(0, $this->freezeColumns).'"/>'
222
+            '<pane xSplit="' . $this->freezeColumns . '" topLeftCell="' .
223
+            Support::xlsCell(0, $this->freezeColumns) . '" activePane="topRight" state="frozen"/>' .
224
+            '<selection activeCell="' . Support::xlsCell(0, $this->freezeColumns) .
225
+            '" activeCellId="0" pane="topRight" sqref="' . Support::xlsCell(0, $this->freezeColumns) . '"/>'
226 226
         );
227 227
     }
228 228
 
Please login to merge, or discard this patch.
src/Writer/Style.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
     protected function addCellStyle($numberFormat, $cellStyleString)
57 57
     {
58 58
         $numberFormatIdx = Support::add2listGetIndex($this->numberFormats, $numberFormat);
59
-        $lookupString    = $numberFormatIdx.';'.$cellStyleString;
59
+        $lookupString    = $numberFormatIdx . ';' . $cellStyleString;
60 60
 
61 61
         return Support::add2listGetIndex($this->cellStyles, $lookupString);
62 62
     }
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
                 }
81 81
                 if (isset($style['border-color']) && is_string($style['border-color']) && '#' == $style['border-color'][0]) {
82 82
                     $v                     = substr($style['border-color'], 1, 6);
83
-                    $v                     = 3 == strlen($v) ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v; // expand cf0 => ccff00
84
-                    $border_value['color'] = 'FF'.strtoupper($v);
83
+                    $v                     = 3 == strlen($v) ? $v[0] . $v[0] . $v[1] . $v[1] . $v[2] . $v[2] : $v; // expand cf0 => ccff00
84
+                    $border_value['color'] = 'FF' . strtoupper($v);
85 85
                 }
86 86
                 $styleIndexes[$i]['border_idx'] = Support::add2listGetIndex($borders, json_encode($borderValue));
87 87
             }
88 88
             if (isset($style['fill']) && is_string($style['fill']) && '#' == $style['fill'][0]) {
89 89
                 $v                            = substr($style['fill'], 1, 6);
90
-                $v                            = 3 == strlen($v) ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v; // expand cf0 => ccff00
91
-                $styleIndexes[$i]['fill_idx'] = Support::add2listGetIndex($fills, 'FF'.strtoupper($v));
90
+                $v                            = 3 == strlen($v) ? $v[0] . $v[0] . $v[1] . $v[1] . $v[2] . $v[2] : $v; // expand cf0 => ccff00
91
+                $styleIndexes[$i]['fill_idx'] = Support::add2listGetIndex($fills, 'FF' . strtoupper($v));
92 92
             }
93 93
             if (isset($style['halign']) && in_array($style['halign'], $this->horizontalAllowed)) {
94 94
                 $styleIndexes[$i]['alignment'] = true;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
             }
101 101
             if (isset($style['wrap_text'])) {
102 102
                 $styleIndexes[$i]['alignment'] = true;
103
-                $styleIndexes[$i]['wrap_text'] = (bool) $style['wrap_text'];
103
+                $styleIndexes[$i]['wrap_text'] = (bool)$style['wrap_text'];
104 104
             }
105 105
 
106 106
             $font = $this->defaultFont;
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
             }
136 136
             if (isset($style['color']) && is_string($style['color']) && '#' == $style['color'][0]) {
137 137
                 $v             = substr($style['color'], 1, 6);
138
-                $v             = 3 == strlen($v) ? $v[0].$v[0].$v[1].$v[1].$v[2].$v[2] : $v; // expand cf0 => ccff00
139
-                $font['color'] = 'FF'.strtoupper($v);
138
+                $v             = 3 == strlen($v) ? $v[0] . $v[0] . $v[1] . $v[1] . $v[2] . $v[2] : $v; // expand cf0 => ccff00
139
+                $font['color'] = 'FF' . strtoupper($v);
140 140
             }
141 141
             if ($font != $this->defaultFont) {
142 142
                 $styleIndexes[$i]['font_idx'] = Support::add2listGetIndex($fonts, json_encode($font));
Please login to merge, or discard this patch.