JobProducer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 6
dl 0
loc 21
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A enqueue() 0 5 1
A __construct() 0 3 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