ProcessManager   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addWorker() 0 25 1
A removeWorker() 0 4 1
1
<?php
2
3
namespace Phppm;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
7
class ProcessManager implements ProcessManagerInterface
8
{
9
    protected $workers;
10
11
    public function addWorker(string $process, OutputInterface $output, int $time)
12
    {
13
        $descriptorspec = [
14
            0 => ["pipe", "r"],  // stdin is a pipe that the child will read from
15
            1 => ["pipe", "w"],  // stdout is a pipe that the child will write to
16
            2 => ["file", "/tmp/error-output.txt", "a"] // stderr is a file to write to
17
        ];
18
19
        $process = proc_open('php', $descriptorspec, $this->pipes);
0 ignored issues
show
Bug introduced by
The property pipes 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...
20
21
        dump(proc_get_status($process));
22
23
        stream_set_blocking($this->pipes[1], 0);
24
        stream_set_blocking($this->pipes[2], 0);
25
        dump($this->pipes);
26
        
27
//        fclose($this->pipes[0]);
28
//        fclose($this->pipes[1]);
29
        
30
//        proc_close($process);
31
        proc_terminate($process);
32
        
33
        
34
//        $this->workers[] = $worker;
35
    }
36
37
    public function removeWorker()
38
    {
39
        // TODO: Implement removeWorker() method.
40
    }
41
}
42