| Total Complexity | 11 |
| Total Lines | 88 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class ParallelProcessor |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var Process[] $processes |
||
| 14 | */ |
||
| 15 | protected array $processes = []; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var array |
||
| 19 | */ |
||
| 20 | private array $config; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var ResponseList $responses |
||
| 24 | */ |
||
| 25 | private ResponseList $responses; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * ParallelProcessor constructor. |
||
| 29 | * @param array $config |
||
| 30 | */ |
||
| 31 | public function __construct(array $config) |
||
| 32 | { |
||
| 33 | $this->clear(); |
||
| 34 | $this->config = $config; |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @param string $label |
||
| 39 | * @param Closure $closure |
||
| 40 | * @return ParallelProcessor |
||
| 41 | */ |
||
| 42 | public function add(string $label, Closure $closure) |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return void |
||
| 50 | */ |
||
| 51 | public function run() |
||
| 52 | { |
||
| 53 | $this->runProcesses(); |
||
| 54 | $this->clear(); |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @return ResponseList |
||
| 59 | */ |
||
| 60 | public function wait() |
||
| 67 | } |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @return void |
||
| 71 | */ |
||
| 72 | private function clear() |
||
| 73 | { |
||
| 74 | $this->processes = []; |
||
| 75 | $this->responses = new ResponseList([]); |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @return void |
||
| 80 | */ |
||
| 81 | private function runProcesses(): void |
||
| 85 | } |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @return void |
||
| 90 | */ |
||
| 91 | private function fetchResults(): void |
||
| 103 |