Passed
Push — main ( b08f68...83c25f )
by Stefan
02:16
created
SKien/XFPDF/XPDF.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 class XPDF extends FPDF
31 31
 {
32 32
     /** predifined Col-ID for automated row number */
33
-    const COL_ROW_NR    = 1000;
33
+    const COL_ROW_NR = 1000;
34 34
     
35 35
     /** Bottom margin for trigger of the auto pagebreak */
36
-    const BOTTOM_MARGIN    = 12;
36
+    const BOTTOM_MARGIN = 12;
37 37
     
38 38
     /** totals info                         */
39 39
     const FLAG_TOTALS       = 0x0007;
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
     /** @var int        index of last totals col         */
162 162
     protected int $iMaxColTotals = -1;
163 163
     /** @var array      calculated totals        */
164
-    protected array $aTotals  = Array();
164
+    protected array $aTotals = Array();
165 165
     /** @var array      calculated subtotals         */
166
-    protected array $aSubTotals  = Array();
166
+    protected array $aSubTotals = Array();
167 167
     /** @var array      colspan of the totals        */
168
-    protected array $aTotalsColSpan  = Array();
168
+    protected array $aTotalsColSpan = Array();
169 169
     /** @var int        current rownumber    */
170 170
     protected int $iRow;
171 171
     /** @var float      lineheight in mm     */
@@ -197,11 +197,11 @@  discard block
 block discarded – undo
197 197
      * @param string|array $size
198 198
      * @see FPDF::__construct()
199 199
      */
200
-    public function __construct(string $orientation='P', string $unit='mm', $size='A4') 
200
+    public function __construct(string $orientation = 'P', string $unit = 'mm', $size = 'A4') 
201 201
     {
202 202
         parent::__construct($orientation, $unit, $size);
203 203
         
204
-        $this->SetDisplayMode('fullpage','single');
204
+        $this->SetDisplayMode('fullpage', 'single');
205 205
         $this->SetAutoPageBreak(true, self::BOTTOM_MARGIN);
206 206
         $this->AliasNbPages('{NP}');
207 207
         $this->SetLocale("en_US.utf8, en_US");
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
      * @param string $strKeywords
227 227
      * @param bool $isUTF8  Indicates if the strings encoded in ISO-8859-1 (false) or UTF-8 (true). (Default: false)
228 228
      */
229
-    public function SetInfo(string $strTitle, string $strSubject, string $strAuthor, string $strKeywords='', bool $isUTF8=false) : void 
229
+    public function SetInfo(string $strTitle, string $strSubject, string $strAuthor, string $strKeywords = '', bool $isUTF8 = false) : void 
230 230
     {
231 231
         $this->SetTitle($strTitle, $isUTF8);
232 232
         $this->SetSubject($strSubject, $isUTF8);
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
      * @see XPDF:SetSubject()
293 293
      * @see XPDF:SetLogo()  
294 294
      */
295
-    public function SetPageHeader(string $strTitle, string $strHeaderSubject='', string $strLogo='') : void
295
+    public function SetPageHeader(string $strTitle, string $strHeaderSubject = '', string $strLogo = '') : void
296 296
     {
297 297
         $this->strPageTitle = $strTitle;
298 298
         if (strlen($strLogo) > 0) {
@@ -365,11 +365,11 @@  discard block
 block discarded – undo
365 365
     public function InitGrid(string $strFilename = '') : void
366 366
     {
367 367
         $this->fontHeader   = new XPDFFont('Arial', 'B', 12);
368
-        $this->fontSubject  = new XPDFFont('Arial', 'I',  8);
369
-        $this->fontFooter   = new XPDFFont('Arial', 'I',  8);
370
-        $this->fontColHeader= new XPDFFont('Arial', 'B', 10);
371
-        $this->fontSubHeader= new XPDFFont('Arial', 'B', 10);
372
-        $this->fontRows     = new XPDFFont('Arial', '',  10);
368
+        $this->fontSubject  = new XPDFFont('Arial', 'I', 8);
369
+        $this->fontFooter   = new XPDFFont('Arial', 'I', 8);
370
+        $this->fontColHeader = new XPDFFont('Arial', 'B', 10);
371
+        $this->fontSubHeader = new XPDFFont('Arial', 'B', 10);
372
+        $this->fontRows     = new XPDFFont('Arial', '', 10);
373 373
         
374 374
         $this->fltLineHeight = 8.0;
375 375
         
@@ -401,27 +401,27 @@  discard block
 block discarded – undo
401 401
             if ($jsonData) {
402 402
                 if (property_exists($jsonData, 'fontHeader')) {
403 403
                     $oFont = $jsonData->fontHeader;
404
-                    $this->fontHeader   = new XPDFFont($oFont->name, $oFont->style, $oFont->size);
404
+                    $this->fontHeader = new XPDFFont($oFont->name, $oFont->style, $oFont->size);
405 405
                 }
406 406
                 if (property_exists($jsonData, 'fontSubject')) {
407 407
                     $oFont = $jsonData->fontSubject;
408
-                    $this->fontSubject  = new XPDFFont($oFont->name, $oFont->style, $oFont->size);
408
+                    $this->fontSubject = new XPDFFont($oFont->name, $oFont->style, $oFont->size);
409 409
                 }
410 410
                 if (property_exists($jsonData, 'fontFooter')) {
411 411
                     $oFont = $jsonData->fontFooter;
412
-                    $this->fontFooter   = new XPDFFont($oFont->name, $oFont->style, $oFont->size);
412
+                    $this->fontFooter = new XPDFFont($oFont->name, $oFont->style, $oFont->size);
413 413
                 }
414 414
                 if (property_exists($jsonData, 'fontColHeader')) {
415 415
                     $oFont = $jsonData->fontColHeader;
416
-                    $this->fontColHeader= new XPDFFont($oFont->name, $oFont->style, $oFont->size);
416
+                    $this->fontColHeader = new XPDFFont($oFont->name, $oFont->style, $oFont->size);
417 417
                 }
418 418
                 if (property_exists($jsonData, 'fontSubHeader')) {
419 419
                     $oFont = $jsonData->fontSubHeader;
420
-                    $this->fontSubHeader= new XPDFFont($oFont->name, $oFont->style, $oFont->size);
420
+                    $this->fontSubHeader = new XPDFFont($oFont->name, $oFont->style, $oFont->size);
421 421
                 }
422 422
                 if (property_exists($jsonData, 'fontRows')) {
423 423
                     $oFont = $jsonData->fontRows;
424
-                    $this->fontRows     = new XPDFFont($oFont->name, $oFont->style, $oFont->size);
424
+                    $this->fontRows = new XPDFFont($oFont->name, $oFont->style, $oFont->size);
425 425
                 }
426 426
                 
427 427
                 $this->fltLineHeight = $this->property($jsonData, 'dblLineHeight', $this->fltLineHeight);
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
                 $this->bStripped = $this->property($jsonData, 'bStripped', $this->bStripped);
446 446
                 $this->border = $this->property($jsonData, 'border', $this->border);
447 447
                 
448
-                $this->bCalcTotals               = $this->property($jsonData, 'bCalcTotals', $this->bCalcTotals);
449
-                $this->bPageTotals   = $this->property($jsonData, 'bPageTotals', $this->bPageTotals);
450
-                $this->bCarryOver        = $this->property($jsonData, 'bCarryOver', $this->bCarryOver);
448
+                $this->bCalcTotals = $this->property($jsonData, 'bCalcTotals', $this->bCalcTotals);
449
+                $this->bPageTotals = $this->property($jsonData, 'bPageTotals', $this->bPageTotals);
450
+                $this->bCarryOver = $this->property($jsonData, 'bCarryOver', $this->bCarryOver);
451 451
                 
452 452
                 $this->strTotals    = $this->property($jsonData, 'strTotals', $this->strTotals);
453 453
                 $this->strPageTotals = $this->property($jsonData, 'strPageTotals', $this->strPageTotals);
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
      * @param string $strSuffix
517 517
      * @see XPDF::InitGrid()
518 518
      */
519
-    public function SetNumberFormat(int $iDecimals, string $strPrefix='', string $strSuffix='') : void
519
+    public function SetNumberFormat(int $iDecimals, string $strPrefix = '', string $strSuffix = '') : void
520 520
     {
521 521
         $this->iNumberDecimals = $iDecimals;
522 522
         $this->strNumberPrefix = $strPrefix;
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
      */
573 573
     public function SetColHeaderFont(string $strFontname, string $strStyle, int $iSize) : void
574 574
     {
575
-        $this->fontColHeader= new XPDFFont($strFontname, $strStyle, $iSize);
575
+        $this->fontColHeader = new XPDFFont($strFontname, $strStyle, $iSize);
576 576
     }
577 577
 
578 578
     /**
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
      */
586 586
     public function SetSubHeaderFont(string $strFontname, string $strStyle, int $iSize) : void
587 587
     {
588
-        $this->fontSubHeader= new XPDFFont($strFontname, $strStyle, $iSize);
588
+        $this->fontSubHeader = new XPDFFont($strFontname, $strStyle, $iSize);
589 589
     }
590 590
     
591 591
     /**
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
      */
599 599
     public function SetRowFont(string $strFontname, string $strStyle, int $iSize) : void
600 600
     {
601
-        $this->fontRows     = new XPDFFont($strFontname, $strStyle, $iSize);
601
+        $this->fontRows = new XPDFFont($strFontname, $strStyle, $iSize);
602 602
         $this->SelectFont($this->fontRows);
603 603
     }
604 604
 
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
      * @param string $strFillColor
649 649
      * @param bool $bStripped
650 650
      */
651
-    public function SetRowColors(string $strTextColor, string $strDrawColor, string $strFillColor, bool $bStripped=true) : void 
651
+    public function SetRowColors(string $strTextColor, string $strDrawColor, string $strFillColor, bool $bStripped = true) : void 
652 652
     {
653 653
         $this->strRowTextColor = $strTextColor;
654 654
         $this->strRowDrawColor = $strDrawColor;
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
      * @see XPDF::InitGrid()
680 680
      * @param int $iTotals  combination of 
681 681
      */
682
-    public function EnableTotals(int $iTotals=self::TOTALS) : void
682
+    public function EnableTotals(int $iTotals = self::TOTALS) : void
683 683
     {
684 684
         $this->bCalcTotals = ($iTotals & self::TOTALS) != 0;
685 685
         $this->bPageTotals = ($iTotals & self::PAGE_TOTALS) != 0;
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
      * @param string $strPageTotals
702 702
      * @param string $strCarryOver
703 703
      */
704
-    public function SetTotalsText(string $strTotals, string $strPageTotals='', string $strCarryOver='') : void
704
+    public function SetTotalsText(string $strTotals, string $strPageTotals = '', string $strCarryOver = '') : void
705 705
     {
706 706
         $this->strTotals = $strTotals;
707 707
         if (strlen($strPageTotals) > 0) {
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
      * @param int $wFlags          Flags to define behaviour for column
723 723
      * @return int                 Index of the inserted col
724 724
      */
725
-    public function AddCol(string $strColHeader, float $fltWidth, string $strAlign, string $strField, int $wFlags=0) : int
725
+    public function AddCol(string $strColHeader, float $fltWidth, string $strAlign, string $strField, int $wFlags = 0) : int
726 726
     {
727 727
         $this->iMaxCol++;
728 728
         $this->aColWidth[$this->iMaxCol] = $fltWidth;
@@ -825,11 +825,11 @@  discard block
 block discarded – undo
825 825
      * @param string $strTotals
826 826
      * @param string $strHeader
827 827
      */
828
-    public function StartGroup(string $strTotals, ?string $strHeader=null) : void
828
+    public function StartGroup(string $strTotals, ?string $strHeader = null) : void
829 829
     {
830 830
         $this->strSubTotals = $strTotals;
831 831
         $iCount = count($this->aSubTotals);
832
-        for ($i=0; $i < $iCount; $i++) {
832
+        for ($i = 0; $i < $iCount; $i++) {
833 833
             $this->aSubTotals[$i] = 0.0;
834 834
         }
835 835
         if ($strHeader) {
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
      */
864 864
     public function SelectTextColor(string $strColor) : void
865 865
     {
866
-        $r=0; $g=0; $b=0;
866
+        $r = 0; $g = 0; $b = 0;
867 867
         $this->getRGB($strColor, $r, $g, $b);
868 868
         $this->SetTextColor($r, $g, $b);
869 869
     }
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
      */
875 875
     public function SelectDrawColor(string $strColor) : void
876 876
     {
877
-        $r=0; $g=0; $b=0;
877
+        $r = 0; $g = 0; $b = 0;
878 878
         $this->getRGB($strColor, $r, $g, $b);
879 879
         $this->SetDrawColor($r, $g, $b);
880 880
     }
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
      */
886 886
     public function SelectFillColor(string $strColor) : void
887 887
     {
888
-        $r=0; $g=0; $b=0;
888
+        $r = 0; $g = 0; $b = 0;
889 889
         $this->getRGB($strColor, $r, $g, $b);
890 890
         $this->SetFillColor($r, $g, $b);
891 891
     }
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
             $bFill = $this->bStripped && (($this->iRow % 2) == 0);
1110 1110
             
1111 1111
             // calc totals if enabled
1112
-            if ($this->bCalcTotals && ($wFlags & self::FLAG_TOTALS_CALC) !=  0) {
1112
+            if ($this->bCalcTotals && ($wFlags & self::FLAG_TOTALS_CALC) != 0) {
1113 1113
                 if (is_numeric($row[$field]) || is_float($row[$field])) {
1114 1114
                     $this->aTotals[$i] += $row[$field]; 
1115 1115
                     $this->aSubTotals[$i] += $row[$field]; 
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
             $link = '';
1135 1135
             if (($wFlags & self::FLAG_INT_LINK) != 0) {
1136 1136
                 $link = $this->InternalLink($i, $row);
1137
-                $this->SetFont('','U');
1137
+                $this->SetFont('', 'U');
1138 1138
                 $this->SelectTextColor($this->strLinkTextColor);
1139 1139
             }
1140 1140
                     
@@ -1148,7 +1148,7 @@  discard block
 block discarded – undo
1148 1148
                 if (isset($this->aImgInfo[$i])) {
1149 1149
                     $fltTop += $this->aImgInfo[$i]['fltTop'];
1150 1150
                     $fltLeft += $this->aImgInfo[$i]['fltLeft'];
1151
-                    if ($this->aImgInfo[$i]['fltHeight'] > 0 ) {
1151
+                    if ($this->aImgInfo[$i]['fltHeight'] > 0) {
1152 1152
                         $fltHeight = $this->aImgInfo[$i]['fltHeight'];
1153 1153
                     }
1154 1154
                     if ($this->aImgInfo[$i]['fltWidth'] > 0) {
@@ -1352,8 +1352,8 @@  discard block
 block discarded – undo
1352 1352
      */
1353 1353
     protected function Col(int $iCol, array $row, /** @scrutinizer ignore-unused */ bool &$bFill) : string 
1354 1354
     {
1355
-        $strCol  ='';
1356
-        switch($iCol) {
1355
+        $strCol = '';
1356
+        switch ($iCol) {
1357 1357
             case self::COL_ROW_NR:
1358 1358
                 $strCol = $this->iRow;
1359 1359
                 break;
@@ -1383,14 +1383,14 @@  discard block
 block discarded – undo
1383 1383
     protected function getRGB(string $strColor, int &$r, int &$g, int &$b) : void
1384 1384
     {
1385 1385
         if ($strColor[0] == '#') {
1386
-            if (strlen( $strColor ) == 7) {
1387
-                $r = intval( substr( $strColor, 1, 2 ), 16);
1388
-                $g = intval( substr( $strColor, 3, 2 ), 16);
1389
-                $b = intval( substr( $strColor, 5, 2 ), 16);
1390
-            } elseif (strlen( $strColor ) == 4) {
1391
-                $r = intval( substr( $strColor, 1, 1 ), 16);
1392
-                $g = intval( substr( $strColor, 2, 1 ), 16);
1393
-                $b = intval( substr( $strColor, 3, 1 ), 16);
1386
+            if (strlen($strColor) == 7) {
1387
+                $r = intval(substr($strColor, 1, 2), 16);
1388
+                $g = intval(substr($strColor, 3, 2), 16);
1389
+                $b = intval(substr($strColor, 5, 2), 16);
1390
+            } elseif (strlen($strColor) == 4) {
1391
+                $r = intval(substr($strColor, 1, 1), 16);
1392
+                $g = intval(substr($strColor, 2, 1), 16);
1393
+                $b = intval(substr($strColor, 3, 1), 16);
1394 1394
                 $r = $r + (16 * $r);
1395 1395
                 $g = $g + (16 * $g);
1396 1396
                 $b = $b + (16 * $b);
@@ -1429,12 +1429,12 @@  discard block
 block discarded – undo
1429 1429
         // Restore line width
1430 1430
         if ($this->LineWidth != $a['lw']) {
1431 1431
             $this->LineWidth = $a['lw'];
1432
-            $this->out(sprintf( '%.2F w', $a['lw'] * $this->k ));
1432
+            $this->out(sprintf('%.2F w', $a['lw'] * $this->k));
1433 1433
         }
1434 1434
         // Restore font
1435 1435
         if (($a['family'] != $this->FontFamily) ||
1436
-             $a['style']  != $this->FontStyle ||
1437
-             $a['size']   != $this->FontSizePt) {
1436
+             $a['style'] != $this->FontStyle ||
1437
+             $a['size'] != $this->FontSizePt) {
1438 1438
             $this->SetFont($a['family'], $a['style'], $a['size']);
1439 1439
         }
1440 1440
         $this->underline = $a['ul'];
@@ -1442,11 +1442,11 @@  discard block
 block discarded – undo
1442 1442
         // Restore colors
1443 1443
         if ($this->DrawColor != $a['dc']) {
1444 1444
             $this->DrawColor = $a['dc'];
1445
-            $this->out( $a['dc']);
1445
+            $this->out($a['dc']);
1446 1446
         }
1447 1447
         if ($this->FillColor != $a['fc']) {
1448 1448
             $this->FillColor = $a['fc'];
1449
-            $this->out( $a['fc']);
1449
+            $this->out($a['fc']);
1450 1450
         }
1451 1451
         $this->TextColor = $a['tc'];
1452 1452
         $this->ColorFlag = $a['cf'];
@@ -1460,7 +1460,7 @@  discard block
 block discarded – undo
1460 1460
      * @param mixed $default
1461 1461
      * @return mixed
1462 1462
      */
1463
-    protected function property(\stdClass $obj, string $strName, $default='')
1463
+    protected function property(\stdClass $obj, string $strName, $default = '')
1464 1464
     {
1465 1465
         $value = $default; 
1466 1466
         if (property_exists($obj, $strName)) {
@@ -1479,7 +1479,7 @@  discard block
 block discarded – undo
1479 1479
         if ($this->strCharset != 'UTF-8') {
1480 1480
             $strText = iconv('UTF-8', $this->strCharset, $strText);
1481 1481
         }
1482
-        return html_entity_decode( $strText, ENT_QUOTES, 'UTF-8');
1482
+        return html_entity_decode($strText, ENT_QUOTES, 'UTF-8');
1483 1483
     }
1484 1484
 
1485 1485
     /**
@@ -1554,7 +1554,7 @@  discard block
 block discarded – undo
1554 1554
      * @param bool $bSymbol
1555 1555
      * @return string
1556 1556
      */
1557
-    protected function formatCurrency(float $fltValue, bool $bSymbol=true) : string
1557
+    protected function formatCurrency(float $fltValue, bool $bSymbol = true) : string
1558 1558
     {
1559 1559
         if (!$this->bInvalidLocale) {
1560 1560
             $li = localeconv();
Please login to merge, or discard this patch.