Conditions | 16 |
Paths | 528 |
Total Lines | 75 |
Code Lines | 53 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 |
||
56 | public function Header() |
||
57 | { |
||
58 | $this->setHeaderTemplateAutoreset(true); |
||
59 | $f = $this->getHeaderFont(); |
||
60 | $f[2] = 12; |
||
61 | $this->setHeaderFont($f); |
||
62 | $this->header_line_color = array(255,255,255); // the line cuts through the pedigree chart in landscape mode |
||
63 | // and no line gives a nicer look |
||
64 | |||
65 | if ($this->header_xobjid === false) { |
||
66 | // start a new XObject Template |
||
67 | $this->header_xobjid = $this->startTemplate($this->w, $this->tMargin); |
||
68 | $headerfont = $this->getHeaderFont(); |
||
69 | $headerdata = $this->getHeaderData(); |
||
70 | $this->y = $this->header_margin; |
||
71 | if ($this->rtl) { |
||
72 | $this->x = $this->w - $this->original_rMargin; |
||
73 | } else { |
||
74 | $this->x = $this->original_lMargin; |
||
75 | } |
||
76 | if (($headerdata['logo']) and ($headerdata['logo'] != K_BLANK_IMAGE)) { |
||
77 | $imgtype = TCPDF_IMAGES::getImageFileType(K_PATH_IMAGES . $headerdata['logo']); |
||
78 | if (($imgtype == 'eps') or ($imgtype == 'ai')) { |
||
79 | $this->ImageEps(K_PATH_IMAGES . $headerdata['logo'], '', '', $headerdata['logo_width']); |
||
80 | } elseif ($imgtype == 'svg') { |
||
81 | $this->ImageSVG(K_PATH_IMAGES . $headerdata['logo'], '', '', $headerdata['logo_width']); |
||
82 | } else { |
||
83 | $this->Image(K_PATH_IMAGES . $headerdata['logo'], '', '', $headerdata['logo_width']); |
||
84 | } |
||
85 | $imgy = $this->getImageRBY(); |
||
86 | } else { |
||
87 | $imgy = $this->y; |
||
88 | } |
||
89 | $cell_height = $this->getCellHeight($headerfont[2] / $this->k); |
||
90 | // set starting margin for text data cell |
||
91 | if ($this->getRTL()) { |
||
92 | $header_x = $this->original_rMargin + ($headerdata['logo_width'] * 1.1); |
||
93 | } else { |
||
94 | $header_x = $this->original_lMargin + ($headerdata['logo_width'] * 1.1); |
||
95 | } |
||
96 | $cw = $this->w - $this->original_lMargin - $this->original_rMargin - ($headerdata['logo_width'] * 1.1); |
||
97 | $this->SetTextColorArray($this->header_text_color); |
||
98 | // header title |
||
99 | $this->SetFont($headerfont[0], 'B', $headerfont[2] + 1); |
||
100 | $this->SetX($header_x); |
||
101 | $this->Cell($cw, $cell_height, $headerdata['title'], 0, 1, 'C', 0, '', 0); |
||
102 | if ($this->page == 1) { // allows for a second line, not used (yet) |
||
103 | // header string |
||
104 | $this->SetFont($headerfont[0], $headerfont[1], $headerfont[2]); |
||
105 | $this->SetX($header_x); |
||
106 | $this->MultiCell($cw, $cell_height, $headerdata['string'], 0, '', 0, 1, '', '', true, 0, false, true, 0, 'T', false); |
||
107 | $this->endTemplate(); |
||
108 | } |
||
109 | } |
||
110 | |||
111 | // print header template |
||
112 | $xx = 0; |
||
113 | if ($this->original_lMargin < 15) { |
||
114 | $xx = 15; // approx 5mm (15/72*25.4) // my Lexmark printer masks ~2 mm at the paper edge |
||
115 | // only applicable on pedigree charts(?) |
||
116 | } |
||
117 | $dx = 0; |
||
118 | if (!$this->header_xobj_autoreset and $this->booklet and (($this->page % 2) == 0)) { |
||
119 | // adjust margins for booklet mode |
||
120 | $dx = ($this->original_lMargin - $this->original_rMargin); |
||
121 | } |
||
122 | if ($this->rtl) { |
||
123 | $x = $this->w + $dx; |
||
124 | } else { |
||
125 | $x = $xx + $dx; |
||
126 | } |
||
127 | $this->printTemplate($this->header_xobjid, $x, 0, 0, 0, '', '', false); |
||
128 | if ($this->header_xobj_autoreset) { |
||
129 | // reset header xobject template at each page |
||
130 | $this->header_xobjid = false; |
||
131 | } |
||
150 |