Passed
Push — master ( 3fec98...825426 )
by Koldo
02:42
created

JobProducer::enqueue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 1
b 0
f 1
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Antidot\Queue;
6
7
use Interop\Queue\Context;
8
9
class JobProducer implements Producer
10
{
11
    private Context $context;
12
13 2
    public function __construct(Context $context)
14
    {
15 2
        $this->context = $context;
16 2
    }
17
18
    /***
19
     * @param Job $job
20
     * @throws \Interop\Queue\Exception
21
     * @throws \Interop\Queue\Exception\InvalidDestinationException
22
     * @throws \Interop\Queue\Exception\InvalidMessageException
23
     * @throws \JsonException
24
     */
25 1
    public function enqueue(Job $job): void
26
    {
27 1
        $queue = $this->context->createQueue($job->queueName());
28 1
        $message = $this->context->createMessage($job->payload());
29 1
        $this->context->createProducer()->send($queue, $message);
30 1
    }
31
}
32