| Conditions | 10 |
| Paths | 6 |
| Total Lines | 38 |
| Code Lines | 26 |
| 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 |
||
| 53 | public function execute() |
||
| 54 | { |
||
| 55 | $this->option->extract(); |
||
| 56 | if (count($this->options)) { |
||
| 57 | $attributes = $this->option->getOptionNames(); |
||
| 58 | foreach ($attributes as $attributeName) { |
||
| 59 | $elementOption = $this->option->getOption($attributeName); |
||
|
|
|||
| 60 | if (!$elementOption) continue; |
||
| 61 | // The options are sorted by their entry into the setOption() method. Need to have it ordered by the page order |
||
| 62 | |||
| 63 | if (!$elementOption instanceof Option) { |
||
| 64 | throw new InvalidConfigurableOptionException('Missing the attribute: ' . $attributeName); |
||
| 65 | } |
||
| 66 | $element = $elementOption->getValue($this->getOption($attributeName)); |
||
| 67 | if (!$element instanceof Value) { |
||
| 68 | throw new InvalidConfigurableOptionException(sprintf('Missing the option %s for the attribute %s ', $this->getOption($attributeName), $attributeName)); |
||
| 69 | } |
||
| 70 | $element->getClickElement()->click(); |
||
| 71 | } |
||
| 72 | } else { |
||
| 73 | $names = $this->option->getOptionNames(); |
||
| 74 | foreach ($names as $name) { |
||
| 75 | $option = $this->option->getOption($name); |
||
| 76 | $items = $option->getValues(); |
||
| 77 | foreach ($items as $item) { |
||
| 78 | if ($item instanceof SwatchValue) { |
||
| 79 | if ($item->getAvailable()) { |
||
| 80 | $item->getClickElement()->click(); |
||
| 81 | break; |
||
| 82 | } |
||
| 83 | } else { |
||
| 84 | $item->getClickElement()->click(); |
||
| 85 | } |
||
| 86 | } |
||
| 87 | } |
||
| 88 | } |
||
| 89 | return parent::execute(); |
||
| 90 | } |
||
| 91 | |||
| 93 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.