| Conditions | 11 |
| Paths | 16 |
| Total Lines | 40 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 |
||
| 76 | public function processVhost($vhostName, array $configuration) |
||
| 77 | { |
||
| 78 | $client = $this->clientPool->getClientByName($configuration['connection']); |
||
| 79 | |||
| 80 | $vhostName = urlencode($vhostName); |
||
| 81 | |||
| 82 | $client->query( |
||
| 83 | ClientInterface::METHOD_PUT, |
||
| 84 | sprintf('/api/vhosts/%s', $vhostName), |
||
| 85 | []); |
||
| 86 | $this->logger->info(sprintf('Create vhost: <info>%s</info>', urldecode($vhostName))); |
||
| 87 | |||
| 88 | //process parameters |
||
| 89 | if (isset($configuration['parameters']) && count($configuration['parameters'])) { |
||
| 90 | |||
| 91 | $this->parameterManager |
||
| 92 | ->setClient($client) |
||
| 93 | ->setVhost($vhostName); |
||
| 94 | foreach ($configuration['parameters'] as $paramType => $parameters) { |
||
| 95 | foreach ($parameters as $paramName => $paramOptions) { |
||
| 96 | $this->parameterManager->create($paramType, $paramName, $paramOptions); |
||
| 97 | } |
||
| 98 | } |
||
| 99 | } |
||
| 100 | |||
| 101 | //process exchanges |
||
| 102 | if (isset($configuration['exchanges']) && count($configuration['exchanges'])) { |
||
| 103 | $this->process($this->exchangeManager, $client, $vhostName, $configuration['exchanges']); |
||
| 104 | } |
||
| 105 | |||
| 106 | //process queues |
||
| 107 | if (isset($configuration['queues']) && count($configuration['queues'])) { |
||
| 108 | $this->process($this->queueManager, $client, $vhostName, $configuration['queues']); |
||
| 109 | } |
||
| 110 | |||
| 111 | //process policies |
||
| 112 | if (isset($configuration['policies']) && count($configuration['policies'])) { |
||
| 113 | $this->process($this->policyManager, $client, $vhostName, $configuration['policies']); |
||
| 114 | } |
||
| 115 | } |
||
| 116 | |||
| 127 |