mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-04 02:14:06 +02:00
cleanup
This commit is contained in:
parent
5986d8552d
commit
73469d2aa1
29 changed files with 140 additions and 149 deletions
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Demostf\API\Demo;
|
||||
|
||||
use Demostf\API\Controllers\TempController;
|
||||
use Exception;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
|
||||
/**
|
||||
|
|
@ -16,25 +16,27 @@ class RawParser {
|
|||
/** @var string */
|
||||
private $parserPath;
|
||||
|
||||
private $tempController;
|
||||
|
||||
public function __construct(string $parserPath, TempController $tempController) {
|
||||
public function __construct(string $parserPath) {
|
||||
$this->parserPath = $parserPath;
|
||||
$this->tempController = $tempController;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @return array|null
|
||||
* @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');
|
||||
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() . ' ' . $url);
|
||||
throw new Exception('Failed to parse demo, ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue