| Conditions | 11 |
| Paths | 7 |
| Total Lines | 20 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 47 | public function addCharsetMeta($page, $param) |
||
|
|
|||
| 48 | { |
||
| 49 | if ($head = $page->getHead()) { |
||
| 50 | $hasCharset = false; |
||
| 51 | $metatags = $head->getMetaTags(); |
||
| 52 | if ($this->_checkMetaCharset) { |
||
| 53 | foreach ($metatags as $meta) { |
||
| 54 | if (empty($meta->getHttpEquiv()) && empty($meta->getContent()) && empty($meta->getName()) && empty($meta->getScheme()) && !empty($meta->getCharset())) { |
||
| 55 | $hasCharset = true; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | } |
||
| 59 | if (!$hasCharset) { |
||
| 60 | $charset = 'utf-8'; |
||
| 61 | if ($globalization = Prado::getApplication()->getGlobalization()) { |
||
| 62 | $charset = $globalization->getCharset(); |
||
| 63 | } |
||
| 64 | $meta = new TMetaTag(); |
||
| 65 | $meta->setCharset($charset); |
||
| 66 | $metatags->add($meta); |
||
| 67 | } |
||
| 87 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.