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.

Process::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Linio\Lock;
6
7
class Process
8
{
9
    /**
10
     * @var int
11
     */
12
    protected $pid;
13
14
    public function __construct()
15
    {
16
        $this->pid = getmypid();
17
    }
18
19
    /**
20
     * @return string
21
     */
22
    public function getApplicationName(): string
23
    {
24
        return basename($_SERVER['argv'][0]);
25
    }
26
27
    /**
28
     * Check if the given pid is an instance of the application.
29
     *
30
     * @param int $pid
31
     *
32
     * @return bool
33
     */
34
    public function isApplicationProcess($pid): bool
35
    {
36
        // This is a workaround to avoid the grep processs to be match
37
        $grepProofPid = preg_replace('/([\d]+)(\d)$/', '$1[$2]', $pid);
38
        $command = sprintf('ps aux | egrep \'%s.*%s( )?\'', $grepProofPid, $this->getApplicationName());
39
40
        exec($command, $output, $result);
41
42
        return $result === 0;
43
    }
44
}
45