threshold = $threshold; parent::__construct($decoratedBatch); } /** * Set the auto-flush threshold * * @param int $threshold The auto-flush threshold * * @return FlushingBatch */ public function setThreshold($threshold) { $this->threshold = $threshold; return $this; } /** * Get the auto-flush threshold * * @return int */ public function getThreshold() { return $this->threshold; } public function add($item) { $this->decoratedBatch->add($item); if (++$this->currentTotal >= $this->threshold) { $this->currentTotal = 0; $this->decoratedBatch->flush(); } return $this; } }