| Conditions | 10 |
| Paths | 17 |
| Total Lines | 34 |
| Code Lines | 27 |
| 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 |
||
| 49 | public function addNoCacheMeta($page, $param) |
||
|
|
|||
| 50 | { |
||
| 51 | if ($head = $page->getHead()) { |
||
| 52 | $hasExpires = $hasPragma = $hasCacheControl = false; |
||
| 53 | $metatags = $head->getMetaTags(); |
||
| 54 | if ($this->_checkMetaNoCache) { |
||
| 55 | foreach ($metatags as $meta) { |
||
| 56 | $httpEquiv = strtolower($meta->getHttpEquiv()); |
||
| 57 | if ($httpEquiv == 'expires') { |
||
| 58 | $hasExpires = true; |
||
| 59 | } elseif ($httpEquiv == 'pragma') { |
||
| 60 | $hasPragma = true; |
||
| 61 | } elseif ($httpEquiv == 'cache-control') { |
||
| 62 | $hasCacheControl = true; |
||
| 63 | } |
||
| 64 | } |
||
| 65 | } |
||
| 66 | if (!$hasExpires) { |
||
| 67 | $meta = new TMetaTag(); |
||
| 68 | $meta->setHttpEquiv('Expires'); |
||
| 69 | $meta->setContent('Fri, Jan 01 1900 00:00:00 GMT'); |
||
| 70 | $metatags->add($meta); |
||
| 71 | } |
||
| 72 | if (!$hasPragma) { |
||
| 73 | $meta = new TMetaTag(); |
||
| 74 | $meta->setHttpEquiv('Pragma'); |
||
| 75 | $meta->setContent('no-cache'); |
||
| 76 | $metatags->add($meta); |
||
| 77 | } |
||
| 78 | if (!$hasCacheControl) { |
||
| 79 | $meta = new TMetaTag(); |
||
| 80 | $meta->setHttpEquiv('Cache-Control'); |
||
| 81 | $meta->setContent('no-cache'); |
||
| 82 | $metatags->add($meta); |
||
| 83 | } |
||
| 103 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.