Conditions | 3 |
Paths | 3 |
Total Lines | 65 |
Code Lines | 53 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
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 |
||
37 | private function output(string $trace_target, Stat $stat): void |
||
38 | { |
||
39 | $this->output->write("\e[H\e[2J"); |
||
40 | $this->output->writeln($trace_target); |
||
41 | $this->output->writeln( |
||
42 | sprintf( |
||
43 | 'samp_count=%d func_count=%d total_count=%d', |
||
44 | $stat->sample_count, |
||
45 | count($stat->function_entries), |
||
46 | $stat->total_count |
||
47 | ) |
||
48 | ); |
||
49 | $this->output->writeln(''); |
||
50 | $count = 7; |
||
51 | $width = $this->terminal->getWidth(); |
||
52 | $height = $this->terminal->getHeight(); |
||
53 | $padding_name = max(0, $width - 41); |
||
54 | |||
55 | $rows = []; |
||
56 | $align_right = new TableCellStyle(['align' => 'right']); |
||
57 | $styled = fn (int|string $content, TableCellStyle $style): TableCell => |
||
58 | new TableCell( |
||
59 | (string)$content, |
||
60 | ['style' => $style] |
||
61 | ) |
||
62 | ; |
||
63 | foreach ($stat->function_entries as $function_entry) { |
||
64 | $name = $function_entry->name; |
||
65 | $percent = number_format($function_entry->percent_exclusive, 2); |
||
66 | $rows[] = [ |
||
67 | $styled($function_entry->total_count_inclusive, $align_right), |
||
68 | $styled($function_entry->total_count_exclusive, $align_right), |
||
69 | $styled($function_entry->count_inclusive, $align_right), |
||
70 | $styled($function_entry->count_exclusive, $align_right), |
||
71 | $styled($percent, $align_right), |
||
72 | $name, |
||
73 | ]; |
||
74 | if (++$count > $height) { |
||
75 | break; |
||
76 | } |
||
77 | } |
||
78 | |||
79 | $output = $this->output->section(); |
||
80 | $table = new Table($output); |
||
81 | $table->setColumnMaxWidth(5, max(4, $width - 41)); |
||
82 | $table->setHeaders([ |
||
83 | $styled('total_incl', $align_right), |
||
84 | $styled('total_excl', $align_right), |
||
85 | $styled('incl', $align_right), |
||
86 | $styled('excl', $align_right), |
||
87 | $styled('%', $align_right), |
||
88 | str_pad('name', $padding_name), |
||
89 | ]); |
||
90 | $table->setRows($rows); |
||
91 | $table->setStyle('compact'); |
||
92 | $table->getStyle()->setCellHeaderFormat('%s'); |
||
93 | $table->render(); |
||
94 | $output->overwrite( |
||
95 | preg_replace( |
||
96 | '/( *total_incl.*)/', |
||
97 | '<bg=bright-white;fg=black>$1</>', |
||
98 | preg_replace( |
||
99 | '/\e[[][A-Za-z0-9]*;?[0-9]*m?/', |
||
100 | '', |
||
101 | $output->getContent() |
||
102 | ) |
||
107 |
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