Synchronous::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 0
nc 1
nop 2
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 1
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