| Conditions | 21 | 
| Paths | 6144 | 
| Total Lines | 67 | 
| Code Lines | 39 | 
| 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 | ||
| 51 | public function __invoke($options = array()) | ||
| 52 |     { | ||
| 53 | parent::__invoke($options); | ||
| 54 | |||
| 55 | $component = clone $this; | ||
| 56 | |||
| 57 |         $component->setHeader('')->setFooter(''); | ||
| 58 | |||
| 59 | // tag options | ||
| 60 |         if ( isset($options["tagname"]) && in_array(strtolower($options["tagname"]), $component->getTags()) ) { | ||
| 61 | $component->setTagname(strtolower($options["tagname"])); | ||
| 62 |         } else { | ||
| 63 |             $component->setTagname('a'); | ||
| 64 | } | ||
| 65 |         if ( isset($options["attributes"]) && is_array($options["attributes"]) ) { | ||
| 66 | $component->setAttributes($options["attributes"]); | ||
| 67 | } | ||
| 68 | |||
| 69 | // bootstrap options | ||
| 70 |         if ( isset($options["size"]) && in_array(strtolower($options["size"]), $component->getSizes()) ) { | ||
| 71 |             $component->addClass('btn-'.strtolower($options["size"]).' '.strtolower($this->_foundations_sizes["size"])); | ||
| 72 | } | ||
| 73 |         if ( isset($options["type"]) && in_array(strtolower($options["type"]), $component->getTypes()) ) { | ||
| 74 |             $component->addClass('btn-'.strtolower($options["type"]).' '.strtolower($options["type"])); | ||
| 75 |         } else { | ||
| 76 |             $component->addClass('btn-default'); | ||
| 77 | } | ||
| 78 |         if ( isset($options["drop"]) ) { | ||
| 79 | $component->setDrop($options["drop"]); | ||
| 80 | } | ||
| 81 |         if ( isset($options["block"]) ) { | ||
| 82 | $component->setBlock($options["block"]); | ||
| 83 | } | ||
| 84 |         if ( isset($options["active"]) ) { | ||
| 85 | $component->setActive($options["active"]); | ||
| 86 | } | ||
| 87 | |||
| 88 |         if ($component->getBlock()) $component->addClass('btn-block expanded'); | ||
| 89 |         if ($component->getActive()) $component->addClass('active'); | ||
| 90 | |||
| 91 |         if ($component->getTagname() == 'a') { | ||
| 92 | $component->setAttributes(array_merge_recursive($component->getAttributes(), array( | ||
| 93 | 'role' => 'button' | ||
| 94 | ))); | ||
| 95 |             if ( isset($options["disabled"]) ) { | ||
| 96 |                 $component->addClass('disabled'); | ||
| 97 | } | ||
| 98 |         } else { | ||
| 99 | $component->setAttributes(array_merge_recursive($component->getAttributes(), array( | ||
| 100 | 'type' => 'button' | ||
| 101 | ))); | ||
| 102 |             if ( isset($options["disabled"]) ) { | ||
| 103 | $component->setAttributes(array_merge_recursive($component->getAttributes(), array( | ||
| 104 | 'disabled' => 'disabled' | ||
| 105 | ))); | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | // tag content | ||
| 110 |         if ( isset($options["label"]) && !empty($options["label"]) ) { | ||
| 111 | $component->setContent($options["label"]); | ||
| 112 |         } else if ( isset($options["content"]) && !empty($options["content"]) ) { | ||
| 113 | $component->setContent($options["content"]); | ||
| 114 | } | ||
| 115 | |||
| 116 | //$component = clone $this; | ||
| 117 | return $component; | ||
| 118 | // return $this; | ||
| 227 | } |