Commit 9dc95366 authored by Mickael Desfrenes's avatar Mickael Desfrenes
Browse files

add convenience methods to JobResult

parent fd857920
......@@ -19,6 +19,31 @@ class JobResult
}
}
public function getDocuments(): \Iterator
{
foreach($this->getFiles() as $file) {
if (!in_array($file->getFileName(), ['out.log', 'job.json'])) {
yield $file;
}
}
}
public function getLog(): \Iterator
{
foreach ($this->getFiles() as $file){
if($file->getFileName() == 'out.log'){
$content = file_get_contents((string)$file);
$lines = explode(PHP_EOL, $content);
foreach ($lines as $line){
$entry = json_decode($line, true);
if($entry){
yield $entry;
}
}
}
}
}
public function __destruct()
{
@\unlink($this->result_file_path);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment