| Conditions | 6 |
| Paths | 17 |
| Total Lines | 53 |
| Code Lines | 34 |
| Lines | 12 |
| Ratio | 22.64 % |
| 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 |
||
| 11 | public function render(BasicObject $o) |
||
|
|
|||
| 12 | { |
||
| 13 | $r = $o->getRepresentation('microtime'); |
||
| 14 | |||
| 15 | if (!$r instanceof MicrotimeRepresentation) { |
||
| 16 | return false; |
||
| 17 | } |
||
| 18 | |||
| 19 | $out = ''; |
||
| 20 | |||
| 21 | if ($o->depth == 0) { |
||
| 22 | $out .= $this->renderer->colorTitle($this->renderer->renderTitle($o)).PHP_EOL; |
||
| 23 | } |
||
| 24 | |||
| 25 | $out .= $this->renderer->renderHeader($o); |
||
| 26 | $out .= $this->renderer->renderChildren($o).PHP_EOL; |
||
| 27 | |||
| 28 | $indent = str_repeat(' ', ($o->depth + 1) * $this->renderer->indent_width); |
||
| 29 | |||
| 30 | $out .= $indent.$this->renderer->colorType('TIME:').' '; |
||
| 31 | $out .= $this->renderer->colorValue($r->getDateTime()->format('Y-m-d H:i:s.u')).PHP_EOL; |
||
| 32 | |||
| 33 | View Code Duplication | if ($r->lap !== null) { |
|
| 34 | $out .= $indent.$this->renderer->colorType('SINCE LAST CALL:').' '; |
||
| 35 | $out .= $this->renderer->colorValue(round($r->lap, 4).'s').'.'.PHP_EOL; |
||
| 36 | } |
||
| 37 | View Code Duplication | if ($r->total !== null) { |
|
| 38 | $out .= $indent.$this->renderer->colorType('SINCE START:').' '; |
||
| 39 | $out .= $this->renderer->colorValue(round($r->total, 4).'s').'.'.PHP_EOL; |
||
| 40 | } |
||
| 41 | View Code Duplication | if ($r->avg !== null) { |
|
| 42 | $out .= $indent.$this->renderer->colorType('AVERAGE DURATION:').' '; |
||
| 43 | $out .= $this->renderer->colorValue(round($r->avg, 4).'s').'.'.PHP_EOL; |
||
| 44 | } |
||
| 45 | |||
| 46 | $bytes = Utils::getHumanReadableBytes($r->mem); |
||
| 47 | $mem = $r->mem.' bytes ('.round($bytes['value'], 3).' '.$bytes['unit'].')'; |
||
| 48 | $bytes = Utils::getHumanReadableBytes($r->mem_real); |
||
| 49 | $mem .= ' (real '.round($bytes['value'], 3).' '.$bytes['unit'].')'; |
||
| 50 | |||
| 51 | $out .= $indent.$this->renderer->colorType('MEMORY USAGE:').' '; |
||
| 52 | $out .= $this->renderer->colorValue($mem).'.'.PHP_EOL; |
||
| 53 | |||
| 54 | $bytes = Utils::getHumanReadableBytes($r->mem_peak); |
||
| 55 | $mem = $r->mem_peak.' bytes ('.round($bytes['value'], 3).' '.$bytes['unit'].')'; |
||
| 56 | $bytes = Utils::getHumanReadableBytes($r->mem_peak_real); |
||
| 57 | $mem .= ' (real '.round($bytes['value'], 3).' '.$bytes['unit'].')'; |
||
| 58 | |||
| 59 | $out .= $indent.$this->renderer->colorType('PEAK MEMORY USAGE:').' '; |
||
| 60 | $out .= $this->renderer->colorValue($mem).'.'.PHP_EOL; |
||
| 61 | |||
| 62 | return $out; |
||
| 63 | } |
||
| 64 | } |
||
| 65 |
Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.