Test Failed
Push — master ( 82b045...1f684d )
by Mike
04:10
created

RabbitMQFacade::runWorker()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Xervice\RabbitMQ\Business;
5
6
use DataProvider\RabbitMqMessageCollectionDataProvider;
7
use DataProvider\RabbitMqMessageDataProvider;
8
use Xervice\Core\Business\Model\Facade\AbstractFacade;
9
10
11
/**
12
 * @method \Xervice\RabbitMQ\Business\RabbitMQBusinessFactory getFactory()
13
 * @method \Xervice\RabbitMQ\RabbitMQConfig getConfig()
14
 */
15
class RabbitMQFacade extends AbstractFacade
16
{
17
    /**
18
     * Initiate the exchanges and queues in RabbitMQ
19
     *
20
     * @api
21
     */
22
    public function init(): void
23
    {
24
        $this->getFactory()->createBootstrapper()->boot();
25
    }
26
27
    public function runWorker(): void
28
    {
29
        $this->getFactory()->createWorker()->runWorker();
30
    }
31
32
    public function close(): void
33
    {
34
        $this->getFactory()->getConnectionProvider()->getConnection()->close();
35
    }
36
37
    /**
38
     * @param \DataProvider\RabbitMqMessageDataProvider $messageDataProvider
39
     */
40
    public function sendMessage(RabbitMqMessageDataProvider $messageDataProvider): void
41
    {
42
        $this->getFactory()->getMessageProvider()->sendMessage($messageDataProvider);
43
    }
44
45
    /**
46
     * @param \DataProvider\RabbitMqMessageCollectionDataProvider $messageCollectionDataProvider
47
     */
48
    public function sendMessages(RabbitMqMessageCollectionDataProvider $messageCollectionDataProvider): void
49
    {
50
        $this->getFactory()->getMessageProvider()->sendBulk($messageCollectionDataProvider);
51
    }
52
}
53