Test Failed
Pull Request — master (#172)
by
unknown
12:31
created

Bill::getPayment()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Sprain\SwissQrBill\PaymentPart\Output\PhpWordOutput\Table;
4
5
use PhpOffice\PhpWord\Element\Cell;
6
use PhpOffice\PhpWord\Element\Section;
7
use PhpOffice\PhpWord\SimpleType\JcTable;
8
use PhpOffice\PhpWord\Style\Table;
9
use PhpOffice\PhpWord\Style\TablePosition;
10
use Sprain\SwissQrBill\PaymentPart\Output\PhpWordOutput\PhpWordHelper;
11
12
class Bill
13
{
14
    private \PhpOffice\PhpWord\Element\Table $table;
15
    private ?Cell $separate = null;
16
    private Receipt $receipt;
17
    private Payment $payment;
18
19
    public function __construct(Section $section, bool $isPrintable)
20
    {
21
        $this->table = $section->addTable([
22
                'layout' => Table::LAYOUT_FIXED,
23
                'width' => PhpWordHelper::mmToTwip(Style::DIN_A4_WIDTH),
24
                'height' => PhpWordHelper::mmToTwip(Style::DIN_A6_WIDTH),
25
                'position' => [
26
                        'horzAnchor' => TablePosition::HANCHOR_PAGE,
27
                        'vertAnchor' => TablePosition::VANCHOR_PAGE,
28
                        'tblpXSpec' => TablePosition::XALIGN_CENTER,
29
                        'tblpYSpec' => TablePosition::YALIGN_BOTTOM,
30
                        'leftFromText' => 0,
31
                        'rightFromText' => 0,
32
                        'topFromText' => 0,
33
                        'bottomFromText' => 0,
34
                ],
35
        ]);
36
        $verticalLine = [];
37
        if (!$isPrintable) {
38
            $width = PhpWordHelper::mmToTwip(Style::DIN_A4_WIDTH);
39
            $height = PhpWordHelper::mmToTwip(5);
40
            $separatorCellStyle = [
41
                    'borderBottomColor' => Style::NON_PRINTABLE_BORDER_COLOR,
42
                    'borderBottomSize' => Style::NON_PRINTABLE_BORDER_SIZE,
43
                    'borderBottomStyle' => Style::NON_PRINTABLE_BORDER_TYPE,
44
                    'gridSpan' => 2,
45
                    'valign' => JcTable::CENTER,
46
            ];
47
            $this->separate = $this->table->addRow($height)->addCell($width, $separatorCellStyle);
0 ignored issues
show
Bug introduced by
$height of type double is incompatible with the type integer expected by parameter $height of PhpOffice\PhpWord\Element\Table::addRow(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

47
            $this->separate = $this->table->addRow(/** @scrutinizer ignore-type */ $height)->addCell($width, $separatorCellStyle);
Loading history...
Bug introduced by
$width of type double is incompatible with the type integer expected by parameter $width of PhpOffice\PhpWord\Element\Row::addCell(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

47
            $this->separate = $this->table->addRow($height)->addCell(/** @scrutinizer ignore-type */ $width, $separatorCellStyle);
Loading history...
48
            $verticalLine = [
49
                    'borderRightColor' => Style::NON_PRINTABLE_BORDER_COLOR,
50
                    'borderRightSize' => Style::NON_PRINTABLE_BORDER_SIZE,
51
                    'borderRightStyle' => Style::NON_PRINTABLE_BORDER_TYPE,
52
            ];
53
        }
54
        $row = $this->table->addRow(PhpWordHelper::mmToTwip(Style::INNER_HEIGHT));
55
        $cell = $row->addCell(PhpWordHelper::mmToTwip(Style::RECEIPT_WIDTH), $verticalLine);
56
        $cell = $cell->addTable([
57
                'layout' => Table::LAYOUT_FIXED,
58
                'width' => PhpWordHelper::percentToPct(100),
59
                'unit' => 'pct',
60
                'cellMargin' => PhpWordHelper::mmToTwip(5),
61
        ])->addRow()->addCell();
62
        $this->receipt = new Receipt($cell);
63
64
        $cell = $row->addCell(PhpWordHelper::mmToTwip(Style::PAYMENT_PART_WIDTH));
65
        $cell = $cell->addTable([
66
                'layout' => Table::LAYOUT_FIXED,
67
                'width' => PhpWordHelper::percentToPct(100),
68
                'unit' => 'pct',
69
                'cellMargin' => PhpWordHelper::mmToTwip(5),
70
        ])->addRow()->addCell();
71
        $this->payment = new Payment($cell);
72
    }
73
74
    public function getSeparate() : ?Cell
75
    {
76
        return $this->separate;
77
    }
78
79
    public function getReceipt() : Receipt
80
    {
81
        return $this->receipt;
82
    }
83
84
    public function getPayment() : Payment
85
    {
86
        return $this->payment;
87
    }
88
}
89