| Conditions | 2 |
| Paths | 2 |
| Total Lines | 55 |
| Code Lines | 39 |
| 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 |
||
| 38 | public function render(RendererRegistry $renderers) { |
||
| 39 | $content = [ |
||
| 40 | new Element('div', ['class' => 'panel-heading'], [ |
||
| 41 | $this->heading, |
||
| 42 | new Element('div', ['class' => 'pull-right'], |
||
| 43 | $this->rightHeading |
||
| 44 | ) |
||
| 45 | ]) |
||
| 46 | ]; |
||
| 47 | |||
| 48 | if ($this->maxHeight) { |
||
|
|
|||
| 49 | $content[] = new Element('div', [ |
||
| 50 | 'class' => 'panel-body', |
||
| 51 | 'style' => 'overflow-x: auto; overflow-y: hidden; max-height: ' . $this->maxHeight, |
||
| 52 | 'data-maxheight' => $this->maxHeight |
||
| 53 | ], [ |
||
| 54 | $renderers->getRenderer($this->content)->render($this->content) |
||
| 55 | ]); |
||
| 56 | $content[] = new Element('div', ['class' => 'panel-footer clearfix'], [ |
||
| 57 | new Element('div', ['class' => 'pull-right'], [ |
||
| 58 | new Element('a', [ |
||
| 59 | 'href' => 'javascript:', |
||
| 60 | 'onclick' => "var body = $(this).closest('.panel').find('.panel-body');" . |
||
| 61 | "body.css('max-height', 'none');" . |
||
| 62 | "body.css('overflow-y', 'visible');" . |
||
| 63 | "$(this).hide(); " . |
||
| 64 | "$(this).next().show();", |
||
| 65 | 'class' => 'show-all' |
||
| 66 | ], [ |
||
| 67 | 'Show all', |
||
| 68 | new Element('span', ['class' => 'glyphicon glyphicon-chevron-down']) |
||
| 69 | ]), |
||
| 70 | new Element('a', [ |
||
| 71 | 'href' => 'javascript:', |
||
| 72 | 'onclick' => "var body = $(this).closest('.panel').find('.panel-body');" . |
||
| 73 | "body.css('max-height', body.data('maxheight'));" . |
||
| 74 | "body.css('overflow-y', 'hidden');" . |
||
| 75 | "$(this).hide();" . |
||
| 76 | "$(this).prev().show();", |
||
| 77 | 'class' => 'show-less', |
||
| 78 | 'style' => 'display: none' |
||
| 79 | ], [ |
||
| 80 | 'Show less', |
||
| 81 | new Element('span', ['class' => 'glyphicon glyphicon-chevron-up']) |
||
| 82 | ]) |
||
| 83 | ]) |
||
| 84 | ]); |
||
| 85 | } else { |
||
| 86 | $content[] = new Element('div', ['class' => 'panel-body'], [ |
||
| 87 | $renderers->getRenderer($this->content)->render($this->content) |
||
| 88 | ]); |
||
| 89 | } |
||
| 90 | |||
| 91 | return new Element('div', ['class' => 'panel panel-default'], $content); |
||
| 92 | } |
||
| 93 | |||
| 125 | } |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: