Synchronous   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 4
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 1
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A putJob() 0 11 2
A __construct() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace JCIT\jobqueue\components\jobQueues;
5
6
use Closure;
7
use JCIT\jobqueue\interfaces\JobInterface;
8
use JCIT\jobqueue\interfaces\JobQueueInterface;
9
use League\Tactician\CommandBus;
10
use Pheanstalk\Contract\PheanstalkInterface;
11
12
class Synchronous implements JobQueueInterface
13
{
14 1
    public function __construct(
15
        private CommandBus $commandBus,
16
        private ?Closure $beforePut = null
17
    ) {
18 1
    }
19
20 1
    public function putJob(
21
        JobInterface $job,
22
        int $priority = PheanstalkInterface::DEFAULT_PRIORITY,
23
        int $delay = PheanstalkInterface::DEFAULT_DELAY,
24
        int $ttr = PheanstalkInterface::DEFAULT_TTR
25
    ): void {
26 1
        if (isset($this->beforePut)) {
27 1
            ($this->beforePut)($job);
28
        }
29
30 1
        $this->commandBus->handle($job);
31 1
    }
32
}
33