public static function build($type, $input, $output, $debug = null)
{
// Support query types: `lexer` / `parser`.
if (!in_array($type, array('lexer', 'parser'))) {
throw new \Exception('Unknown test type (expected `lexer` or `parser`).');
}
/**
* The query that is used to generate the test.
*
* @var string $query
*/
$query = file_get_contents($input);
// There is no point in generating a test without a query.
if (empty($query)) {
throw new \Exception('No input query specified.');
}
$test = static::generate($query, $type);
// Writing test's data.
file_put_contents($output, serialize($test));
// Dumping test's data in human readable format too (if required).
if (!empty($debug)) {
file_put_contents($debug, print_r($test, true));
}
}