| Conditions | 31 |
| Paths | > 20000 |
| Total Lines | 145 |
| Code Lines | 84 |
| 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 |
||
| 34 | public function render($renderer): void |
||
| 35 | { |
||
| 36 | if (str_contains($this->text, '{{:ptp:}}')) { |
||
| 37 | return; |
||
| 38 | } |
||
| 39 | $temptext = str_replace('#PAGENUM#', (string) $renderer->pageNo(), $this->text); |
||
| 40 | // underline «title» part of Source item |
||
| 41 | $temptext = str_replace([ |
||
| 42 | '«', |
||
| 43 | '»', |
||
| 44 | ], [ |
||
| 45 | '<u>', |
||
| 46 | '</u>', |
||
| 47 | ], $temptext); |
||
| 48 | |||
| 49 | // Set up the text style |
||
| 50 | if ($renderer->getCurrentStyle() !== $this->styleName) { |
||
| 51 | $renderer->setCurrentStyle($this->styleName); |
||
| 52 | } |
||
| 53 | |||
| 54 | // If (Future-feature-enable/disable cell padding) |
||
| 55 | $cP = $renderer->cPadding; |
||
| 56 | |||
| 57 | // Adjust the positions |
||
| 58 | if ($this->left === ReportBaseElement::CURRENT_POSITION) { |
||
|
|
|||
| 59 | $this->left = $renderer->getX(); |
||
| 60 | } else { |
||
| 61 | $renderer->setX($this->left); |
||
| 62 | } |
||
| 63 | |||
| 64 | if ($this->top === ReportBaseElement::CURRENT_POSITION) { |
||
| 65 | $this->top = $renderer->getY(); |
||
| 66 | } else { |
||
| 67 | $renderer->setY($this->top); |
||
| 68 | } |
||
| 69 | |||
| 70 | // Start collecting the HTML code |
||
| 71 | echo '<div class="', $this->styleName, '" style="position:absolute;top:', $this->top, 'pt;'; |
||
| 72 | // Use Cell around padding to support RTL also |
||
| 73 | echo 'padding:', $cP, 'pt;'; |
||
| 74 | // LTR (left) or RTL (right) |
||
| 75 | echo $renderer->alignRTL, ':', $this->left, 'pt;'; |
||
| 76 | |||
| 77 | // Background color |
||
| 78 | if (!empty($this->bgcolor)) { |
||
| 79 | echo 'background-color:', $this->bgcolor, ';'; |
||
| 80 | } |
||
| 81 | |||
| 82 | // Borders |
||
| 83 | $bpixX = 0; |
||
| 84 | $bpixY = 0; |
||
| 85 | if (!empty($this->border)) { |
||
| 86 | // Border all around |
||
| 87 | if ($this->border === '1') { |
||
| 88 | echo ' border:solid ', $this->bocolor ?: 'black', ' 1pt;'; |
||
| 89 | $bpixX = 1; |
||
| 90 | $bpixY = 1; |
||
| 91 | } else { |
||
| 92 | if (str_contains($this->border, 'T')) { |
||
| 93 | echo ' border-top:solid ', $this->bocolor ?: 'black', ' 1pt;'; |
||
| 94 | $bpixY = 1; |
||
| 95 | } |
||
| 96 | if (str_contains($this->border, 'B')) { |
||
| 97 | echo ' border-bottom:solid ', $this->bocolor ?: 'black', ' 1pt;'; |
||
| 98 | $bpixY = 1; |
||
| 99 | } |
||
| 100 | if (str_contains($this->border, 'R')) { |
||
| 101 | echo ' border-right:solid ', $this->bocolor ?: 'black', ' 1pt;'; |
||
| 102 | $bpixX = 1; |
||
| 103 | } |
||
| 104 | if (str_contains($this->border, 'L')) { |
||
| 105 | echo ' border-left:solid ', $this->bocolor ?: 'black', ' 1pt;'; |
||
| 106 | $bpixX = 1; |
||
| 107 | } |
||
| 108 | } |
||
| 109 | } |
||
| 110 | // Check the width if set to page wide OR set by xml to larger then page wide |
||
| 111 | if ($this->width === 0.0 || $this->width > $renderer->getRemainingWidth()) { |
||
| 112 | $this->width = $renderer->getRemainingWidth(); |
||
| 113 | } |
||
| 114 | // We have to calculate a different width for the padding, counting on both side |
||
| 115 | $cW = $this->width - $cP * 2.0; |
||
| 116 | |||
| 117 | // If there is any text |
||
| 118 | if (!empty($temptext)) { |
||
| 119 | // Wrap the text |
||
| 120 | $temptext = $renderer->textWrap($temptext, $cW); |
||
| 121 | $tmph = $renderer->getTextCellHeight($temptext); |
||
| 122 | // Add some cell padding |
||
| 123 | $this->height += $cP; |
||
| 124 | if ($tmph > $this->height) { |
||
| 125 | $this->height = $tmph; |
||
| 126 | } |
||
| 127 | } |
||
| 128 | // Check the last cell height and adjust the current cell height if needed |
||
| 129 | if ($renderer->lastCellHeight > $this->height) { |
||
| 130 | $this->height = $renderer->lastCellHeight; |
||
| 131 | } |
||
| 132 | echo ' width:', $cW - $bpixX, 'pt;height:', $this->height - $bpixY, 'pt;'; |
||
| 133 | |||
| 134 | // Text alignment |
||
| 135 | switch ($this->align) { |
||
| 136 | case 'C': |
||
| 137 | echo ' text-align:center;'; |
||
| 138 | break; |
||
| 139 | case 'L': |
||
| 140 | echo ' text-align:left;'; |
||
| 141 | break; |
||
| 142 | case 'R': |
||
| 143 | echo ' text-align:right;'; |
||
| 144 | break; |
||
| 145 | } |
||
| 146 | |||
| 147 | // Print the collected HTML code |
||
| 148 | echo '">'; |
||
| 149 | |||
| 150 | // Print URL |
||
| 151 | if (!empty($this->url)) { |
||
| 152 | echo '<a href="', $this->url, '">'; |
||
| 153 | } |
||
| 154 | // Print any text if exists |
||
| 155 | if (!empty($temptext)) { |
||
| 156 | $renderer->write($temptext, $this->tcolor, false); |
||
| 157 | } |
||
| 158 | if (!empty($this->url)) { |
||
| 159 | echo '</a>'; |
||
| 160 | } |
||
| 161 | // Finish the cell printing and start to clean up |
||
| 162 | echo "</div>\n"; |
||
| 163 | |||
| 164 | // Where to place the next position |
||
| 165 | if ($this->newline === 0) { |
||
| 166 | // -> Next to this cell in the same line |
||
| 167 | $renderer->setXy($this->left + $this->width, $this->top); |
||
| 168 | $renderer->lastCellHeight = $this->height; |
||
| 169 | } elseif ($this->newline === 1) { |
||
| 170 | // -> On a new line at the margin - Default |
||
| 171 | $renderer->setXy(0, $renderer->getY() + $this->height + $cP * 2); |
||
| 172 | // Reset the last cell height for the next line |
||
| 173 | $renderer->lastCellHeight = 0; |
||
| 174 | } elseif ($this->newline === 2) { |
||
| 175 | // -> On a new line at the end of this cell |
||
| 176 | $renderer->setXy($renderer->getX() + $this->width, $renderer->getY() + $this->height + $cP * 2); |
||
| 177 | // Reset the last cell height for the next line |
||
| 178 | $renderer->lastCellHeight = 0; |
||
| 179 | } |
||
| 182 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths