| Conditions | 20 |
| Paths | 768 |
| Total Lines | 38 |
| Code Lines | 22 |
| 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 |
||
| 34 | public function __invoke($options = array()) |
||
| 35 | { |
||
| 36 | if ( is_object($options) && method_exists($options, 'toArray') ) { |
||
| 37 | $options = $options->toArray(); |
||
| 38 | } else if ( is_object($options) ) { |
||
| 39 | $options = (array)$options; |
||
| 40 | } |
||
| 41 | |||
| 42 | if (isset($options['container']) && (null !== $options['container'])) { |
||
| 43 | $this->setContainer($options['container']); |
||
| 44 | } |
||
| 45 | |||
| 46 | if (isset($options['tagname']) && (null !== $options['tagname'])) { |
||
| 47 | $this->setTagname($options['tagname']); |
||
| 48 | } |
||
| 49 | if (isset($options['class']) && (null !== $options['class'])) { |
||
| 50 | $this->setClassnames($options['class']); |
||
| 51 | } |
||
| 52 | if (isset($options['classnames']) && (null !== $options['classnames'])) { |
||
| 53 | $this->setClassnames($options['classnames']); |
||
| 54 | } |
||
| 55 | |||
| 56 | if (isset($options['attr']) && (null !== $options['attr'])) { |
||
| 57 | $this->setAttributes($options['attr']); |
||
| 58 | } |
||
| 59 | if (isset($options['attributes']) && (null !== $options['attributes'])) { |
||
| 60 | $this->setAttributes($options['attributes']); |
||
| 61 | } |
||
| 62 | |||
| 63 | if (isset($options['content']) && (null !== $options['content'])) { |
||
| 64 | $this->setContent($options['content']); |
||
| 65 | } |
||
| 66 | if (isset($options['children']) && (null !== $options['children'])) { |
||
| 67 | $this->setContent($options['children']); |
||
| 68 | } |
||
| 69 | |||
| 70 | $component = clone $this; |
||
| 71 | return $component; |
||
| 72 | } |
||
| 74 | } |