| Conditions | 1 |
| Paths | 1 |
| Total Lines | 54 |
| Code Lines | 45 |
| 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 |
||
| 15 | public function testProcess() |
||
| 16 | { |
||
| 17 | $container = new ContainerBuilder(); |
||
| 18 | |||
| 19 | $count = count($container->getDefinitions()); |
||
| 20 | $compilerPass = new RabbitMQCompilerPass(); |
||
| 21 | $compilerPass->process($container); |
||
| 22 | self::assertEquals($count, count($container->getDefinitions())); |
||
| 23 | |||
| 24 | $rabbitMQOptions = [ |
||
| 25 | 'host' => 'somehost', |
||
| 26 | 'port' => 1234, |
||
| 27 | 'user' => 'asdf', |
||
| 28 | 'password' => 'pass', |
||
| 29 | 'vhost' => 'vhoster', |
||
| 30 | 'queue_args' => [], |
||
| 31 | 'exchange_args' => [], |
||
| 32 | ]; |
||
| 33 | $container = new ContainerBuilder(); |
||
| 34 | $count = count($container->getDefinitions()); |
||
| 35 | $container->setParameter('dtc_queue.rabbit_mq', $rabbitMQOptions); |
||
| 36 | $definition = new Definition(); |
||
| 37 | $definition->setClass(JobManager::class); |
||
| 38 | $container->addDefinitions(['dtc_queue.job_manager.rabbit_mq' => $definition]); |
||
| 39 | $compilerPass = new RabbitMQCompilerPass(); |
||
| 40 | $compilerPass->process($container); |
||
| 41 | |||
| 42 | self::assertGreaterThan($count, count($container->getDefinitions())); |
||
| 43 | self::assertTrue($container->hasDefinition('dtc_queue.rabbit_mq')); |
||
| 44 | self::assertEquals(AMQPStreamConnection::class, $container->getDefinition('dtc_queue.rabbit_mq')->getClass()); |
||
| 45 | |||
| 46 | $rabbitMQOptions = [ |
||
| 47 | 'host' => 'somehost', |
||
| 48 | 'port' => 1234, |
||
| 49 | 'user' => 'asdf', |
||
| 50 | 'password' => 'pass', |
||
| 51 | 'vhost' => 'vhoster', |
||
| 52 | 'ssl' => true, |
||
| 53 | 'queue_args' => [], |
||
| 54 | 'exchange_args' => [], |
||
| 55 | ]; |
||
| 56 | $container = new ContainerBuilder(); |
||
| 57 | $count = count($container->getDefinitions()); |
||
| 58 | $container->setParameter('dtc_queue.rabbit_mq', $rabbitMQOptions); |
||
| 59 | $definition = new Definition(); |
||
| 60 | $definition->setClass(JobManager::class); |
||
| 61 | $container->addDefinitions(['dtc_queue.job_manager.rabbit_mq' => $definition]); |
||
| 62 | $compilerPass = new RabbitMQCompilerPass(); |
||
| 63 | $compilerPass->process($container); |
||
| 64 | |||
| 65 | self::assertGreaterThan($count, count($container->getDefinitions())); |
||
| 66 | self::assertTrue($container->hasDefinition('dtc_queue.rabbit_mq')); |
||
| 67 | self::assertEquals(AMQPSSLConnection::class, $container->getDefinition('dtc_queue.rabbit_mq')->getClass()); |
||
| 68 | } |
||
| 69 | } |
||
| 70 |