ProcessExecutor::createProcess()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.3332

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 11
ccs 4
cts 6
cp 0.6667
rs 10
cc 3
nc 3
nop 1
crap 3.3332
1
<?php
2
3
namespace Tarantool\JobQueue\Executor;
4
5
use Symfony\Component\Process\Process;
6
use Tarantool\JobQueue\Exception\BadPayloadException;
7
use Tarantool\Queue\Queue;
8
9
class ProcessExecutor implements Executor
10
{
11 1
    public function execute($payload, Queue $queue): void
12
    {
13 1
        $process = $this->createProcess($payload);
14 1
        $process->mustRun();
15 1
    }
16
17 1
    private function createProcess($payload): Process
18
    {
19 1
        if ($payload instanceof Process) {
20
            return $payload;
21
        }
22
23 1
        if (is_string($payload)) {
24 1
            return new Process($payload);
0 ignored issues
show
Bug introduced by
$payload of type string is incompatible with the type array expected by parameter $command of Symfony\Component\Process\Process::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

24
            return new Process(/** @scrutinizer ignore-type */ $payload);
Loading history...
25
        }
26
27
        throw BadPayloadException::unexpectedType($payload, 'string or '.Process::class, __CLASS__);
28
    }
29
}
30