Code Duplication    Length = 17-21 lines in 3 locations

src/Intraface/modules/debtor/Visitor/Pdf.php 2 locations

@@ 83-99 (lines=17) @@
80
81
        if ($debtor->get('message')) {
82
            $text = explode("\r\n", $debtor->get('message'));
83
            foreach ($text as $line) {
84
                if ($line == "") {
85
                    $this->doc->setY('-'.$this->doc->get("font_spacing"));
86
                    if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
87
                        $this->doc->nextPage(true);
88
                    }
89
                } else {
90
                    while ($line != "") {
91
                        $this->doc->setY('-'.($this->doc->get("font_padding_top") + $this->doc->get("font_size")));
92
                        $line = $this->doc->addTextWrap($this->doc->get('margin_left'), $this->doc->get('y'), $this->doc->get('content_width'), $this->doc->get("font_size"), $line);
93
                        $this->doc->setY('-'.$this->doc->get("font_padding_bottom"));
94
                        if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
95
                            $this->doc->nextPage(true);
96
                        }
97
                    }
98
                }
99
            }
100
        }
101
102
        // Headlines for the products
@@ 334-351 (lines=18) @@
331
            }
332
333
            $text = explode("\r\n", $debtor->getInvoiceText());
334
            foreach ($text as $line) {
335
                if ($line == "") {
336
                    $this->doc->setY('-'.$this->doc->get("font_spacing"));
337
                    if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
338
                        $this->doc->nextPage(true);
339
                    }
340
                } else {
341
                    while ($line != "") {
342
                        $this->doc->setY('-'.($this->doc->get("font_padding_top") + $this->doc->get("font_size")));
343
                        $line = $this->doc->addTextWrap($this->doc->get('margin_left'), $this->doc->get('y'), $this->doc->get('content_width'), $this->doc->get("font_size"), $line);
344
                        $this->doc->setY('-'.$this->doc->get("font_padding_bottom"));
345
346
                        if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
347
                            $this->doc->nextPage(true);
348
                        }
349
                    }
350
                }
351
            }
352
        }
353
    }
354
}

src/Intraface/modules/invoice/Pdf/Reminder.php 1 location

@@ 60-80 (lines=21) @@
57
        $this->doc->setY('-20'); // space to the product list
58
59
        $text = explode("\r\n", $reminder->get("text"));
60
        foreach ($text as $line) {
61
            if ($line == "") {
62
                $this->doc->setY('-'.$this->doc->get('font_spacing'));
63
64
                if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
65
                    $this->doc->nextPage(true);
66
                }
67
            } else {
68
                while ($line != "") {
69
                    $this->doc->setY('-'.($this->doc->get("font_padding_top") + $this->doc->get("font_size")));
70
                    $line = $this->doc->addTextWrap($this->doc->get('x'), $this->doc->get('y'), $this->doc->get("right_margin_position") - $this->doc->get('x'), $this->doc->get("font_size"), $line); // $this->doc->get("right_margin_position") - $this->doc->get('x')
71
              
72
                    $this->doc->setY('-'.$this->doc->get("font_padding_bottom"));
73
74
                    if ($this->doc->get('y') < $this->doc->get("margin_bottom") + $this->doc->get("font_spacing") * 2) {
75
                        $this->doc->nextPage(true);
76
                    }
77
                }
78
            }
79
        }
80
81
        // Headlines for products
82
83
        $this->doc->setY('-20'); // space to product list