| 1 | <?php declare(strict_types=1); |
||
| 7 | private bool $shouldBatch; |
||
|
|
|||
| 8 | |||
| 9 | private ?int $maxBatchSize; |
||
| 10 | |||
| 11 | private bool $shouldCache; |
||
| 12 | |||
| 13 | public function __construct( |
||
| 14 | ?int $maxBatchSize = null, |
||
| 15 | bool $shouldBatch = true, |
||
| 16 | bool $shouldCache = true |
||
| 17 | ) { |
||
| 18 | $this->validateMaxBatchSizeOption($maxBatchSize); |
||
| 19 | $this->shouldBatch = $shouldBatch; |
||
| 20 | $this->maxBatchSize = $maxBatchSize; |
||
| 21 | $this->shouldCache = $shouldCache; |
||
| 22 | } |
||
| 23 | |||
| 24 | 34 | public function shouldBatch(): bool |
|
| 25 | { |
||
| 26 | return $this->shouldBatch; |
||
| 27 | } |
||
| 28 | |||
| 29 | 34 | public function getMaxBatchSize(): ?int |
|
| 30 | 33 | { |
|
| 31 | 33 | return $this->maxBatchSize; |
|
| 32 | 33 | } |
|
| 33 | 33 | ||
| 34 | public function shouldCache(): bool |
||
| 35 | 30 | { |
|
| 36 | return $this->shouldCache; |
||
| 37 | 30 | } |
|
| 38 | |||
| 39 | private function validateMaxBatchSizeOption(?int $maxBatchSize) |
||
| 40 | 29 | { |
|
| 41 | if ($maxBatchSize !== null && $maxBatchSize < 0) { |
||
| 42 | 29 | throw new \InvalidArgumentException('Expected argument $maxBatchSize to be null or a positive integer'); |
|
| 43 | } |
||
| 44 | } |
||
| 45 | } |
||
| 46 |