| Conditions | 16 | 
| Paths | 518 | 
| Total Lines | 81 | 
| Code Lines | 63 | 
| 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  | 
            ||
| 86 | public function setupRabbitMQ(ContainerBuilder $container)  | 
            ||
| 87 |     { | 
            ||
| 88 |         if ($container->hasParameter('dtc_queue.rabbit_mq')) { | 
            ||
| 89 | $class = 'PhpAmqpLib\\Connection\\AMQPStreamConnection';  | 
            ||
| 90 |             $rabbitMqConfig = $container->getParameter('dtc_queue.rabbit_mq'); | 
            ||
| 91 | $arguments = [  | 
            ||
| 92 | $rabbitMqConfig['host'],  | 
            ||
| 93 | $rabbitMqConfig['port'],  | 
            ||
| 94 | $rabbitMqConfig['user'],  | 
            ||
| 95 | $rabbitMqConfig['password'],  | 
            ||
| 96 | $rabbitMqConfig['vhost'],  | 
            ||
| 97 | ];  | 
            ||
| 98 | |||
| 99 |             if ($container->hasParameter('dtc_queue.rabbit_mq.ssl') && $container->getParameter('dtc_queue.rabbit_mq.ssl')) { | 
            ||
| 100 | $class = 'PhpAmqpLib\\Connection\\AMQPSSLConnection';  | 
            ||
| 101 |                 if ($container->hasParameter('dtc_queue.rabbit_mq.ssl_options')) { | 
            ||
| 102 |                     $arguments[] = $container->getParameter('dtc_queue.rabbit_mq.ssl_options'); | 
            ||
| 103 |                 } else { | 
            ||
| 104 | $arguments[] = [];  | 
            ||
| 105 | }  | 
            ||
| 106 |                 if ($container->hasParameter('dtc_queue.rabbit_mq.options')) { | 
            ||
| 107 |                     $arguments[] = $container->getParameter('dtc_queue.rabbit_mq.options'); | 
            ||
| 108 | }  | 
            ||
| 109 |             } else { | 
            ||
| 110 |                 if ($container->hasParameter('dtc_queue.rabbit_mq.options')) { | 
            ||
| 111 |                     $options = $container->getParameter('dtc_queue.rabbit_mq.options'); | 
            ||
| 112 |                     if (isset($options['insist'])) { | 
            ||
| 113 | $arguments[] = $options['insist'];  | 
            ||
| 114 |                     } else { | 
            ||
| 115 | $arguments[] = false;  | 
            ||
| 116 | }  | 
            ||
| 117 |                     if (isset($options['login_method'])) { | 
            ||
| 118 | $arguments[] = $options['login_method'];  | 
            ||
| 119 |                     } else { | 
            ||
| 120 | $arguments[] = 'AMQPLAIN';  | 
            ||
| 121 | }  | 
            ||
| 122 |                     if (isset($options['login_response'])) { | 
            ||
| 123 | $arguments[] = $options['login_response'];  | 
            ||
| 124 |                     } else { | 
            ||
| 125 | $arguments[] = null;  | 
            ||
| 126 | }  | 
            ||
| 127 |                     if (isset($options['locale'])) { | 
            ||
| 128 | $arguments[] = $options['locale'];  | 
            ||
| 129 |                     } else { | 
            ||
| 130 | $arguments[] = 'en_US';  | 
            ||
| 131 | }  | 
            ||
| 132 |                     if (isset($options['connection_timeout'])) { | 
            ||
| 133 | $arguments[] = $options['connection_timeout'];  | 
            ||
| 134 |                     } else { | 
            ||
| 135 | $arguments[] = 3.0;  | 
            ||
| 136 | }  | 
            ||
| 137 |                     if (isset($options['read_write_timeout'])) { | 
            ||
| 138 | $arguments[] = $options['read_write_timeout'];  | 
            ||
| 139 |                     } else { | 
            ||
| 140 | $arguments[] = 3.0;  | 
            ||
| 141 | }  | 
            ||
| 142 |                     if (isset($options['context'])) { | 
            ||
| 143 | $arguments[] = $options['context'];  | 
            ||
| 144 |                     } else { | 
            ||
| 145 | $arguments[] = null;  | 
            ||
| 146 | }  | 
            ||
| 147 |                     if (isset($options['keepalive'])) { | 
            ||
| 148 | $arguments[] = $options['keepalive'];  | 
            ||
| 149 |                     } else { | 
            ||
| 150 | $arguments[] = false;  | 
            ||
| 151 | }  | 
            ||
| 152 |                     if (isset($options['heartbeat'])) { | 
            ||
| 153 | $arguments[] = $options['heartbeat'];  | 
            ||
| 154 |                     } else { | 
            ||
| 155 | $arguments[] = 0;  | 
            ||
| 156 | }  | 
            ||
| 157 | }  | 
            ||
| 158 | }  | 
            ||
| 159 | $definition = new Definition($class, $arguments);  | 
            ||
| 160 |             $container->setDefinition('dtc_queue.rabbit_mq', $definition); | 
            ||
| 161 |             $definition = $container->getDefinition('dtc_queue.job_manager.rabbit_mq'); | 
            ||
| 162 |             $definition->addMethodCall('setAMQPConnection', [new Reference('dtc_queue.rabbit_mq')]); | 
            ||
| 163 |             $definition->addMethodCall('setQueueArgs', array_values($rabbitMqConfig['queue_args'])); | 
            ||
| 164 |             $definition->addMethodCall('setExchangeArgs', array_values($rabbitMqConfig['exchange_args'])); | 
            ||
| 165 | }  | 
            ||
| 166 | }  | 
            ||
| 167 | |||
| 203 |