ProcessExecutor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 4 1
A createProcess() 0 11 3
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