-
Notifications
You must be signed in to change notification settings - Fork 147
Open
Description
I have a very large csv file. So I don't need to have a full parsing on my local-machine and want to exit after 2000 rows. I'm using throwing exception for now like this:
$interpreter->addObserver(function (array $row) use (&$i, &$captions) {
// todo remove it for non-local server
if ($i > 2000) {
throw new StrictViolationException('Cant exit with another way', 100);
/* return / return false don't work -
* it still continues and I don't need exit() function
*/
}
$i++;
//do smth...
});
try {
$lexer->parse($file, $interpreter);
} catch (StrictViolationException $e) {
// we'll be here
}
print_r("script continues and that's great");
So what's the best way to go out from observer?
Metadata
Metadata
Assignees
Labels
No labels