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

ProcessWorker   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 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->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