Total Complexity | 7 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
13 | class DoctrineBatchHelper implements DoctrineBatchHelperInterface |
||
14 | { |
||
15 | private EntityManagerInterface $em; |
||
16 | |||
17 | 4 | public function __construct(EntityManagerInterface $em) |
|
18 | { |
||
19 | 4 | $this->em = $em; |
|
20 | 4 | } |
|
21 | |||
22 | /** |
||
23 | * @throws Throwable |
||
24 | */ |
||
25 | 4 | public function wrapIterable(iterable $resultSet, int $batchSize): iterable |
|
45 | 3 | } |
|
46 | |||
47 | 3 | private function flushAndClearBatch(int $iteration, int $batchSize): void |
|
48 | { |
||
49 | 3 | if ($iteration % $batchSize) { |
|
50 | 2 | return; |
|
51 | } |
||
52 | |||
53 | 2 | $this->flushAndClearEntityManager(); |
|
54 | 1 | } |
|
55 | |||
56 | 4 | private function flushAndClearEntityManager(): void |
|
60 | 3 | } |
|
61 | } |
||
62 |