GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

SynchronousProcess::start()   A
last analyzed

Complexity

Conditions 3
Paths 6

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 6
nop 0
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\Async\Process;
4
5
use Spatie\Async\Task;
6
use Throwable;
7
8
class SynchronousProcess implements Runnable
9
{
10
    protected $id;
11
12
    protected $task;
13
14
    protected $output;
15
    protected $errorOutput;
16
    protected $executionTime;
17
18
    use ProcessCallbacks;
19
20
    public function __construct(callable $task, int $id)
21
    {
22
        $this->id = $id;
23
        $this->task = $task;
24
    }
25
26
    public static function create(callable $task, int $id): self
27
    {
28
        return new self($task, $id);
29
    }
30
31
    public function getId(): int
32
    {
33
        return $this->id;
34
    }
35
36
    public function getPid(): ?int
37
    {
38
        return $this->getId();
39
    }
40
41
    public function start()
42
    {
43
        $startTime = microtime(true);
44
45
        try {
46
            $this->output = $this->task instanceof Task
47
                ? $this->task->run()
48
                : call_user_func($this->task);
49
        } catch (Throwable $throwable) {
50
            $this->errorOutput = $throwable;
51
        } finally {
52
            $this->executionTime = microtime(true) - $startTime;
53
        }
54
    }
55
56
    public function stop($timeout = 0): void
57
    {
58
    }
59
60
    public function getOutput()
61
    {
62
        return $this->output;
63
    }
64
65
    public function getErrorOutput()
66
    {
67
        return $this->errorOutput;
68
    }
69
70
    public function getCurrentExecutionTime(): float
71
    {
72
        return $this->executionTime;
73
    }
74
75
    protected function resolveErrorOutput(): Throwable
76
    {
77
        return $this->getErrorOutput();
78
    }
79
}
80