Conditions | 2 |
Paths | 2 |
Total Lines | 29 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 2 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | 2 | public function indexAction() |
|
20 | { |
||
21 | /** @var \Zend\Console\Request $request */ |
||
22 | 2 | $request = $this->getRequest(); |
|
23 | /** @var \Zend\Console\Response $response */ |
||
24 | 2 | $response = $this->getResponse(); |
|
25 | |||
26 | 2 | $producerName = $request->getParam('name'); |
|
27 | 2 | $route = $request->getParam('route', ''); |
|
28 | 2 | $msg = $request->getParam('msg'); |
|
29 | |||
30 | 2 | $serviceName = sprintf('rabbitmq_module.producer.%s', $producerName); |
|
31 | |||
32 | 2 | if (!$this->container->has($serviceName)) { |
|
33 | 1 | $this->getConsole()->writeLine( |
|
34 | 1 | sprintf('No producer with name "%s" found', $producerName), |
|
35 | ColorInterface::RED |
||
36 | 1 | ); |
|
37 | 1 | $response->setErrorLevel(1); |
|
38 | |||
39 | 1 | return $response; |
|
40 | } |
||
41 | |||
42 | /** @var \RabbitMqModule\Producer $producer */ |
||
43 | 1 | $producer = $this->container->get($serviceName); |
|
44 | 1 | $producer->publish($msg, $route); |
|
45 | |||
46 | 1 | return $response; |
|
47 | } |
||
48 | } |
||
49 |