| Conditions | 10 |
| Paths | 17 |
| Total Lines | 43 |
| 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 |
||
| 62 | public function getPersistentParameters() |
||
| 63 | { |
||
| 64 | $parameters = parent::getPersistentParameters(); |
||
| 65 | |||
| 66 | if (!$this->hasRequest()) { |
||
| 67 | return $parameters; |
||
| 68 | } |
||
| 69 | |||
| 70 | $filter = $this->getRequest()->get('filter'); |
||
| 71 | if ($filter && \array_key_exists('context', $this->getRequest()->get('filter'))) { |
||
| 72 | $context = $filter['context']['value']; |
||
| 73 | } else { |
||
| 74 | $context = $this->getRequest()->get('context', $this->pool->getDefaultContext()); |
||
| 75 | } |
||
| 76 | |||
| 77 | $providers = $this->pool->getProvidersByContext($context); |
||
| 78 | $provider = $this->getRequest()->get('provider'); |
||
| 79 | |||
| 80 | // if the context has only one provider, set it into the request |
||
| 81 | // so the intermediate provider selection is skipped |
||
| 82 | if (1 === \count($providers) && null === $provider) { |
||
| 83 | $provider = array_shift($providers)->getName(); |
||
| 84 | $this->getRequest()->query->set('provider', $provider); |
||
| 85 | } |
||
| 86 | |||
| 87 | // if there is a post server error, provider is not posted and in case of |
||
| 88 | // multiple providers, it has to be persistent to not being lost |
||
| 89 | if (1 < \count($providers) && null !== $provider) { |
||
| 90 | $parameters['provider'] = $provider; |
||
| 91 | } |
||
| 92 | |||
| 93 | $categoryId = $this->getRequest()->get('category'); |
||
| 94 | |||
| 95 | if (null !== $this->categoryManager && !$categoryId) { |
||
| 96 | $categoryId = $this->categoryManager->getRootCategory($context)->getId(); |
||
|
|
|||
| 97 | } |
||
| 98 | |||
| 99 | return array_merge($parameters, [ |
||
| 100 | 'context' => $context, |
||
| 101 | 'category' => $categoryId, |
||
| 102 | 'hide_context' => (bool) $this->getRequest()->get('hide_context'), |
||
| 103 | ]); |
||
| 104 | } |
||
| 105 | |||
| 197 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.