Open Journal Systems  3.3.0
FlushingBatch.php
1 <?php
2 
3 namespace Guzzle\Batch;
4 
9 {
11  protected $threshold;
12 
14  protected $currentTotal = 0;
15 
21  {
22  $this->threshold = $threshold;
23  parent::__construct($decoratedBatch);
24  }
25 
33  public function setThreshold($threshold)
34  {
35  $this->threshold = $threshold;
36 
37  return $this;
38  }
39 
45  public function getThreshold()
46  {
47  return $this->threshold;
48  }
49 
50  public function add($item)
51  {
52  $this->decoratedBatch->add($item);
53  if (++$this->currentTotal >= $this->threshold) {
54  $this->currentTotal = 0;
55  $this->decoratedBatch->flush();
56  }
57 
58  return $this;
59  }
60 }
Guzzle\Batch\FlushingBatch\$currentTotal
$currentTotal
Definition: FlushingBatch.php:20
Guzzle\Batch
Definition: AbstractBatchDecorator.php:3
Guzzle\Batch\FlushingBatch
Definition: FlushingBatch.php:8
Guzzle\Batch\FlushingBatch\setThreshold
setThreshold($threshold)
Definition: FlushingBatch.php:39
Guzzle\Batch\FlushingBatch\__construct
__construct(BatchInterface $decoratedBatch, $threshold)
Definition: FlushingBatch.php:26
Guzzle\Batch\FlushingBatch\$threshold
$threshold
Definition: FlushingBatch.php:14
Guzzle\Batch\BatchInterface
Definition: BatchInterface.php:8
Guzzle\Batch\FlushingBatch\add
add($item)
Definition: FlushingBatch.php:56
Guzzle\Batch\AbstractBatchDecorator\$decoratedBatch
$decoratedBatch
Definition: AbstractBatchDecorator.php:14
Guzzle\Batch\AbstractBatchDecorator
Definition: AbstractBatchDecorator.php:8
Guzzle\Batch\FlushingBatch\getThreshold
getThreshold()
Definition: FlushingBatch.php:51