| Conditions | 10 |
| Paths | 14 |
| Total Lines | 31 |
| Code Lines | 19 |
| 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 |
||
| 177 | public function getChannel() |
||
| 178 | { |
||
| 179 | if (!$this->connection) { |
||
| 180 | try { |
||
| 181 | if (function_exists('socket_create')) { |
||
| 182 | $this->connection = new AMQPSocketConnection($this->host, $this->port, $this->user, $this->password); |
||
| 183 | } else { |
||
| 184 | $this->connection = new AMQPStreamConnection($this->host, $this->port, $this->user, $this->password); |
||
| 185 | } |
||
| 186 | } catch (\ErrorException $e) { |
||
|
|
|||
| 187 | /* We are trying to catch the exception when the connection if refused */ |
||
| 188 | if (preg_match("/.*unable to connect.*Connection refused.*/", $e->__toString())) { |
||
| 189 | throw new ConnectionException("Cannot create the connection", 404, $e); |
||
| 190 | } |
||
| 191 | throw $e; |
||
| 192 | } catch (AMQPIOException $e) { |
||
| 193 | throw new ConnectionException("Cannot create the connection", 404, $e); |
||
| 194 | } |
||
| 195 | $this->channel = $this->connection->channel(); |
||
| 196 | |||
| 197 | if ($this->prefetchSize !== null || $this->prefetchCount !== null || $this->aGlobal !== null) { |
||
| 198 | $this->channel->basic_qos($this->prefetchSize, $this->prefetchCount, $this->aGlobal); |
||
| 199 | } |
||
| 200 | |||
| 201 | foreach ($this->rabbitMqObjects as $rabbitMqObject) { |
||
| 202 | $rabbitMqObject->init($this->channel); |
||
| 203 | } |
||
| 204 | } |
||
| 205 | |||
| 206 | return $this->channel; |
||
| 207 | } |
||
| 208 | |||
| 221 |
Scrutinizer analyzes your
composer.json/composer.lockfile if available to determine the classes, and functions that are defined by your dependencies.It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.