| Total Complexity | 6 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | class SequentialProcessHandler extends BaseProcessHandler |
||
| 18 | { |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var Broker |
||
| 22 | */ |
||
| 23 | private $broker; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param Broker $broker The event broker. |
||
| 27 | */ |
||
| 28 | public function __construct(Broker $broker) |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Run the processes sequentially to gather information. |
||
| 35 | * |
||
| 36 | * @param Generator $filesFinder Collection of files. |
||
| 37 | * @param ProcessFactory $processFactory Process Factory. |
||
| 38 | */ |
||
| 39 | public function process(Generator $filesFinder, ProcessFactory $processFactory): void |
||
| 40 | { |
||
| 41 | foreach ($filesFinder as $file) { |
||
| 42 | $result = new Result($file); |
||
| 43 | |||
| 44 | foreach ($processFactory->createProcesses($file) as $process) { |
||
| 45 | $this->executeProcess($process, $result); |
||
| 46 | } |
||
| 47 | |||
| 48 | $this->broker->notify(new AfterFileAnalysisEvent($result)); |
||
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Execute a process and save the result when it's done. |
||
| 54 | * |
||
| 55 | * @param ProcessInterface $process The process to execute. |
||
| 56 | * @param Result $result The result to complete. |
||
| 57 | */ |
||
| 58 | private function executeProcess(ProcessInterface $process, Result $result): void |
||
| 65 | } |
||
| 66 | } |
||
| 67 |