protected function limitTo($limit)
{
if ($limit instanceof DateInterval) {
$interval = $limit;
$terminationCondition = new Quantifier\TimeBasedTerminationCondition('time', $interval);
$this->listeners[] = $terminationCondition;
$this->terminationConditions[] = $terminationCondition;
} elseif (is_integer($limit)) {
$this->iterations = $limit;
} else {
throw new InvalidArgumentException("The limit " . var_export($limit, true) . " is not valid. Please pass an integer or DateInterval.");
}
return $this;
}