| Conditions | 6 | 
| Paths | 4 | 
| Total Lines | 61 | 
| Code Lines | 39 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 5 | ||
| Bugs | 0 | Features | 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 | ||
| 145 | protected function displayComment($comment, $depth = 0) | ||
| 146 |     { | ||
| 147 |         echo Html::beginTag('div', [ | ||
| 148 | 'id' => 'comment-' . $comment->id, | ||
| 149 | 'class' => $comment->child ? 'parent depth-' . $depth : 'depth-' . $depth, | ||
| 150 | ]); | ||
| 151 | |||
| 152 |         if (Option::get('show_avatars')) { | ||
| 153 | ?> | ||
| 154 | <div class="media-left avatar"> | ||
| 155 | <?= Gravatar::widget([ | ||
| 156 | 'email' => $comment->email, | ||
| 157 | 'options' => [ | ||
| 158 | 'alt' => $comment->author, | ||
| 159 | 'class' => 'avatar', | ||
| 160 | 'width' => $this->avatarSize, | ||
| 161 | 'height' => $this->avatarSize, | ||
| 162 | ], | ||
| 163 |                     'defaultImage' => Option::get('avatar_default'), | ||
| 164 |                     'rating' => Option::get('avatar_rating'), | ||
| 165 | 'size' => $this->avatarSize, | ||
| 166 | ]) ?> | ||
| 167 | |||
| 168 | </div> | ||
| 169 | <?php | ||
| 170 | |||
| 171 | } | ||
| 172 | ?> | ||
| 173 | <div class="media-body comment-body"> | ||
| 174 | <p class="meta"> | ||
| 175 | <strong class="author vcard"> | ||
| 176 | <span class="fn"> | ||
| 177 |                         <?= $comment->author ? $comment->author : \Yii::t('writesdown', 'Anonymous') ?> | ||
| 178 | |||
| 179 | </span> | ||
| 180 | </strong> | ||
| 181 | - | ||
| 182 | <time class="date published" datetime="<?= \Yii::$app | ||
| 183 | ->formatter | ||
| 184 | ->asDatetime($comment->date) ?>"> | ||
| 185 | <?= \Yii::$app->formatter->asDate($comment->date) ?> | ||
| 186 | |||
| 187 | </time> | ||
| 188 | |||
| 189 |                 <?php if ($depth < $this->maxDepth && $this->enableThreadComments) { | ||
| 190 |                     echo Html::a(\Yii::t('writesdown', 'Reply'), '#', [ | ||
| 191 | 'class' => 'comment-reply-link', | ||
| 192 | 'data-id' => $comment->id, | ||
| 193 | ]); | ||
| 194 | } | ||
| 195 | ?> | ||
| 196 | |||
| 197 | </p> | ||
| 198 | <div class="comment-content"> | ||
| 199 | <?= $comment->content ?> | ||
| 200 | |||
| 201 | </div> | ||
| 202 | </div> | ||
| 203 | <?php | ||
| 204 |         echo Html::endTag('div'); | ||
| 205 | } | ||
| 206 | |||
| 245 |