Synchronous::putJob()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 3
nc 2
nop 4
dl 0
loc 11
ccs 4
cts 4
cp 1
crap 2
rs 10
c 1
b 0
f 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