Completed
Push — master ( ea15e4...6b748c )
by Michał
04:07
created

ProcessWorker::runProcess()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
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->process = new $process($output);
29
        $this->interval = $interval;
30
    }
31
32
    public function runProcess()
33
    {
34
        while (true) {
35
            $this->process->exec();
36
            usleep($this->interval * 1000);
37
        }
38
    }
39
}
40