| Conditions | 16 |
| Paths | > 20000 |
| Total Lines | 73 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | 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 |
||
| 129 | private function createConnectionByType(): AbstractConnection |
||
| 130 | { |
||
| 131 | $config = new AMQPConnectionConfig(); |
||
| 132 | |||
| 133 | $config->setHost($this->connectionDetails['hostname']); |
||
| 134 | $config->setPort($this->connectionDetails['port']); |
||
| 135 | $config->setUser($this->connectionDetails['username']); |
||
| 136 | $config->setPassword($this->connectionDetails['password']); |
||
| 137 | $config->setVhost($this->connectionDetails['vhost']); |
||
| 138 | |||
| 139 | if (!empty($this->connectionDetails['io_type'])) { |
||
| 140 | $config->setIoType($this->connectionDetails['io_type']); |
||
| 141 | } |
||
| 142 | |||
| 143 | if (!empty($this->connectionDetails['connection_name'])) { |
||
| 144 | $config->setConnectionName($this->connectionDetails['connection_name']); |
||
| 145 | } |
||
| 146 | |||
| 147 | if (isset($this->connectionDetails['connect_timeout'])) { |
||
| 148 | $config->setConnectionTimeout((float)$this->connectionDetails['connect_timeout']); |
||
| 149 | } |
||
| 150 | |||
| 151 | if (isset($this->connectionDetails['read_write_timeout'])) { |
||
| 152 | $config->setReadTimeout((float)$this->connectionDetails['read_write_timeout']); |
||
| 153 | $config->setWriteTimeout((float)$this->connectionDetails['read_write_timeout']); |
||
| 154 | |||
| 155 | } |
||
| 156 | |||
| 157 | if (isset($this->connectionDetails['channel_rpc_timeout'])) { |
||
| 158 | $config->setChannelRPCTimeout((float)$this->connectionDetails['channel_rpc_timeout']); |
||
| 159 | } |
||
| 160 | |||
| 161 | if (isset($this->connectionDetails['keep_alive'])) { |
||
| 162 | $config->setKeepalive((bool)$this->connectionDetails['keep_alive']); |
||
| 163 | } |
||
| 164 | |||
| 165 | if (isset($this->connectionDetails['heartbeat'])) { |
||
| 166 | $config->setHeartbeat((int)$this->connectionDetails['heartbeat']); |
||
| 167 | } |
||
| 168 | |||
| 169 | if (isset($this->connectionDetails['secure'])) { |
||
| 170 | $config->setIsSecure((bool)$this->connectionDetails['secure']); |
||
| 171 | } |
||
| 172 | |||
| 173 | if (isset($this->connectionDetails['ssl_crypto_method'])) { |
||
| 174 | $config->setSslCryptoMethod($this->connectionDetails['ssl_crypto_method']); |
||
| 175 | } |
||
| 176 | |||
| 177 | if (isset($this->connectionDetails['ssl_verify_name'])) { |
||
| 178 | $config->setSslVerifyName((bool)$this->connectionDetails['ssl_verify_name']); |
||
| 179 | } |
||
| 180 | |||
| 181 | if (isset($this->connectionDetails['ssl_verify'])) { |
||
| 182 | $config->setSslVerify((bool)$this->connectionDetails['ssl_verify']); |
||
| 183 | } |
||
| 184 | |||
| 185 | if (isset($this->connectionDetails['lazy'])) { |
||
| 186 | $config->setIsLazy((bool)$this->connectionDetails['lazy']); |
||
| 187 | } |
||
| 188 | |||
| 189 | if (isset($this->connectionDetails['insist'])) { |
||
| 190 | $config->setInsist((bool)$this->connectionDetails['insist']); |
||
| 191 | } |
||
| 192 | |||
| 193 | if (!empty($this->connectionDetails['locale'])) { |
||
| 194 | $config->setLocale($this->connectionDetails['locale']); |
||
| 195 | } |
||
| 196 | |||
| 197 | if (!empty($this->connectionDetails['login_response'])) { |
||
| 198 | $config->setLoginResponse($this->connectionDetails['login_response']); |
||
| 199 | } |
||
| 200 | |||
| 201 | return AMQPConnectionFactory::create($config); |
||
| 202 | } |
||
| 234 |