| Conditions | 11 |
| Paths | 20 |
| Total Lines | 24 |
| 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 |
||
| 14 | protected function _prepareCollection() |
||
| 15 | { |
||
| 16 | parent::_prepareCollection(); |
||
| 17 | $collection = $this->getCollection(); |
||
| 18 | $turpentineEnabled = false; |
||
| 19 | $fullPageEnabled = false; |
||
| 20 | foreach ($collection as $key=>$item) { |
||
| 21 | if ($item->getStatus() == 1 && ($item->getId() == 'turpentine_pages' || $item->getId() == 'turpentine_esi_blocks')) { |
||
| 22 | $turpentineEnabled = true; |
||
| 23 | } |
||
| 24 | if ($item->getStatus() == 1 && $item->getId() == 'full_page') { |
||
| 25 | $fullPageEnabled = true; |
||
| 26 | } |
||
| 27 | } |
||
| 28 | if ($turpentineEnabled && !$fullPageEnabled) { |
||
| 29 | $collection->removeItemByKey('full_page'); |
||
| 30 | } |
||
| 31 | if ($fullPageEnabled && !$turpentineEnabled) { |
||
| 32 | $collection->removeItemByKey('turpentine_pages'); |
||
| 33 | $collection->removeItemByKey('turpentine_esi_blocks'); |
||
| 34 | } |
||
| 35 | $this->setCollection($collection); |
||
| 36 | return $this; |
||
| 37 | } |
||
| 38 | |||
| 40 |