parserPath = $parserPath; } /** * @throws Exception */ public function parse(string $path): ?array { try { $command = $this->parserPath . ' ' . escapeshellarg($path); $output = shell_exec($command); $result = \GuzzleHttp\json_decode($output, true); if (null === $result) { throw new Exception('Failed to parse demo, unexpected result from parser'); } else { return $result; } } catch (RequestException $e) { throw new Exception('Failed to parse demo, ' . $e->getMessage()); } } }