ProcessTaskRunner   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 25
ccs 9
cts 11
cp 0.8182
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 2
A supports() 0 3 1
1
<?php
2
3
namespace Zenstruck\ScheduleBundle\Schedule\Task\Runner;
4
5
use Zenstruck\ScheduleBundle\Schedule\Task;
6
use Zenstruck\ScheduleBundle\Schedule\Task\ProcessTask;
7
use Zenstruck\ScheduleBundle\Schedule\Task\Result;
8
use Zenstruck\ScheduleBundle\Schedule\Task\TaskRunner;
9
10
/**
11
 * @author Kevin Bond <[email protected]>
12
 */
13
final class ProcessTaskRunner implements TaskRunner
14
{
15
    /**
16
     * @param ProcessTask $task
17
     */
18 2
    public function __invoke(Task $task): Result
19
    {
20 2
        $process = clone $task->getProcess();
0 ignored issues
show
Bug introduced by
The method getProcess() does not exist on Zenstruck\ScheduleBundle\Schedule\Task. It seems like you code against a sub-type of Zenstruck\ScheduleBundle\Schedule\Task such as Zenstruck\ScheduleBundle\Schedule\Task\ProcessTask. ( Ignorable by Annotation )

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

20
        $process = clone $task->/** @scrutinizer ignore-call */ getProcess();
Loading history...
21
22 2
        $process->run();
23
24 2
        if ($process->isSuccessful()) {
25 1
            return Result::successful($task, $process->getOutput());
26
        }
27
28 1
        return Result::failure(
29 1
            $task,
30 1
            "Exit {$process->getExitCode()}: {$process->getExitCodeText()}",
31 1
            $process->getOutput().$process->getErrorOutput()
32
        );
33
    }
34
35
    public function supports(Task $task): bool
36
    {
37
        return $task instanceof ProcessTask;
38
    }
39
}
40