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.

ProcessManager::startProcess()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 29
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 12
c 2
b 0
f 0
nc 4
nop 7
dl 0
loc 29
ccs 13
cts 13
cp 1
crap 3
rs 9.8666
1
<?php
2
3
namespace Webparking\QueueEnsurer\Processes;
4
5
class ProcessManager
6
{
7 4
    public function isStillRunning(int $processId): bool
8
    {
9 4
        return posix_kill($processId, 0);
10
    }
11
12 3
    public function startProcess(
13
        string $phpPath,
14
        string $queueName,
15
        ?string $connection,
16
        bool $specifyQueue,
17
        int $timeout,
18
        int $sleep,
19
        int $tries
20
    ): int {
21 3
        $command = $phpPath;
22 3
        $command .= ' artisan queue:work';
23
24 3
        if (null !== $connection) {
25 1
            $command .= ' ' . $connection;
26
        }
27
28 3
        if ($specifyQueue) {
29 3
            $command .= ' --queue ' . $queueName;
30
        }
31
32 3
        $command .= ' --timeout ' . $timeout;
33 3
        $command .= ' --sleep ' . $sleep;
34 3
        $command .= ' --tries ' . $tries;
35
36
        // Suppress output and return PID
37 3
        $command .= ' > /dev/null & echo $!';
38
39 3
        return (int) exec(
40 3
            $command
41
        );
42
    }
43
44 2
    public function killProcess(int $processId): void
45
    {
46 2
        posix_kill($processId, 9);
47 2
    }
48
}
49