mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 18:04:08 +02:00
split parser and add tests
This commit is contained in:
parent
1c37d3513e
commit
ae39548ddb
11 changed files with 1801 additions and 102 deletions
27
src/Demo/RawParser.php
Normal file
27
src/Demo/RawParser.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Demostf\API\Demo;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
/**
|
||||
* Wrapper around demo.js parser
|
||||
*
|
||||
* Doesn't do any post-processing on the result
|
||||
*/
|
||||
class RawParser {
|
||||
/** @var string */
|
||||
private $parserUrl;
|
||||
|
||||
public function __construct(string $parserUrl) {
|
||||
$this->parserUrl = $parserUrl;
|
||||
}
|
||||
|
||||
public function parse(string $path): ?array {
|
||||
$client = new Client();
|
||||
$response = $client->post($this->parserUrl, [
|
||||
'body' => fopen($path, 'r')
|
||||
]);
|
||||
return json_decode($response->getBody(), true);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue