Conditions | 2 |
Paths | 2 |
Total Lines | 53 |
Code Lines | 45 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
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); |
||
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 | } |
||
89 |