1
0
Fork 0
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:
Robin Appelman 2017-04-08 23:25:33 +02:00
commit ae39548ddb
11 changed files with 1801 additions and 102 deletions

27
src/Demo/RawParser.php Normal file
View 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);
}
}