ProcessWorker   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A runProcess() 0 7 2
1
<?php
2
3
namespace Phppm;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
7
class ProcessWorker
8
{
9
    /**
10
     * @var int
11
     */
12
    protected $interval;
13
14
    /**
15
     * @var ProcessInterface
16
     */
17
    public $process;
18
19
    /**
20
     * ProcessWorker constructor.
21
     *
22
     * @param string $process
23
     * @param OutputInterface $output
24
     * @param int $interval
25
     */
26
    public function __construct(string $process, OutputInterface $output, int $interval = 100)
27
    {
28
        $this->pid = getmypid();
0 ignored issues
show
Bug introduced by
The property pid does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
29
        $this->process = new $process($output, $this);
30
        $this->interval = $interval;
31
32
        //???
33
    }
34
35
    public function runProcess()
36
    {
37
        while (true) {
38
            $this->process->exec();
39
            usleep($this->interval * 1000);
40
        }
41
    }
42
}
43