| Conditions | 4 |
| Paths | 12 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | 4 | public function __invoke(Environment $env, Arguments $arguments, Options $options): void |
|
| 31 | { |
||
| 32 | 4 | $queue = $arguments->get('queue'); |
|
| 33 | 4 | $consume = $this->consumers->get($queue); |
|
| 34 | 4 | $basic = $this->client->channel()->basic(); |
|
| 35 | |||
| 36 | 4 | if ($arguments->contains('prefetch')) { |
|
| 37 | 1 | $basic->qos(new Qos(0, (int) $arguments->get('prefetch'))); |
|
| 38 | 3 | } else if ($arguments->contains('number')) { |
|
| 39 | 1 | $basic->qos(new Qos(0, (int) $arguments->get('number'))); |
|
| 40 | } |
||
| 41 | |||
| 42 | 4 | $consumer = $basic->consume(new Basic\Consume($queue)); |
|
| 43 | |||
| 44 | 4 | if ($arguments->contains('number')) { |
|
| 45 | 2 | $consumer->take((int) $arguments->get('number')); |
|
| 46 | } |
||
| 47 | |||
| 48 | try { |
||
| 49 | 4 | $consumer->foreach($consume); |
|
| 50 | 3 | } finally { |
|
| 51 | 4 | $this->client->close(); |
|
| 52 | } |
||
| 64 |