Conditions | 2 |
Paths | 2 |
Total Lines | 64 |
Code 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 |
||
67 | public function prepend(ContainerBuilder $container) |
||
68 | { |
||
69 | $configs = $container->getExtensionConfig($this->getAlias()); |
||
70 | $currentConfig = $this->processConfiguration(new Configuration($this->getAlias()), $configs); |
||
71 | |||
72 | $rabbitMQConfig = array( |
||
73 | 'consumers' => array(), |
||
74 | 'producers' => array(), |
||
75 | ); |
||
76 | |||
77 | foreach ($currentConfig['drivers'] as $driverId => $driver) { |
||
78 | $exchangeOptions = array( |
||
79 | 'name' => $driver['exchange_name'], |
||
80 | 'type' => 'topic', |
||
81 | ); |
||
82 | |||
83 | $rabbitMQConfig['producers'][$driver['producer_name']] = array( |
||
84 | 'connection' => $driver['rabbitmq_connection'], |
||
85 | 'exchange_options' => $exchangeOptions, |
||
86 | ); |
||
87 | |||
88 | $rabbitMQConfig['consumers'][$driver['consumer_name']] = array( |
||
89 | 'connection' => $driver['rabbitmq_connection'], |
||
90 | 'exchange_options' => $exchangeOptions, |
||
91 | 'queue_options' => array( |
||
92 | 'name' => $driver['consumer_queue_name'], |
||
93 | 'durable' => true, |
||
94 | 'auto_delete' => false, |
||
95 | 'routing_keys' => array('*'), |
||
96 | ), |
||
97 | 'qos_options' => array( |
||
98 | 'prefetch_size' => 0, |
||
99 | 'prefetch_count' => 1, |
||
100 | 'global' => false, |
||
101 | ), |
||
102 | 'callback' => 'gendoria_command_queue_rabbit_mq_driver.worker.'.$driverId, |
||
103 | ); |
||
104 | |||
105 | $rabbitMQConfig['producers'][$driver['producer_name'].'_reschedule_delayed'] = array( |
||
106 | 'connection' => $driver['rabbitmq_connection'], |
||
107 | 'exchange_options' => array_merge($exchangeOptions, array( |
||
108 | 'name' => $driver['exchange_name'].'-reschedule-delayed', |
||
109 | )), |
||
110 | ); |
||
111 | |||
112 | $rabbitMQConfig['consumers'][$driver['consumer_name'].'_reschedule_delayed'] = array( |
||
113 | 'connection' => $driver['rabbitmq_connection'], |
||
114 | 'exchange_options' => $rabbitMQConfig['producers'][$driver['producer_name'].'_reschedule_delayed']['exchange_options'], |
||
115 | 'queue_options' => array( |
||
116 | 'name' => $driver['consumer_queue_name'].'-reschedule-delayed', |
||
117 | 'durable' => true, |
||
118 | 'auto_delete' => false, |
||
119 | 'routing_keys' => array('*'), |
||
120 | 'arguments' => array( |
||
121 | 'x-dead-letter-exchange' => array('S', $exchangeOptions['name']), |
||
122 | 'x-message-ttl' => array('I', 600000), //10 minutes |
||
123 | ), |
||
124 | ), |
||
125 | 'callback' => 'gendoria_command_queue_rabbit_mq_driver.services_reschedule_worker', |
||
126 | ); |
||
127 | } |
||
128 | |||
129 | $container->prependExtensionConfig('old_sound_rabbit_mq', $rabbitMQConfig); |
||
130 | } |
||
131 | } |
||
132 |