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