Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
25 | 4 | public function wrapIterable(iterable $resultSet, int $batchSize): iterable |
|
26 | { |
||
27 | 4 | $iteration = 0; |
|
28 | |||
29 | 4 | $this->em->beginTransaction(); |
|
30 | |||
31 | try { |
||
32 | 4 | foreach ($resultSet as $key => $value) { |
|
33 | 3 | $iteration++; |
|
34 | 3 | yield $key => $value; |
|
35 | 3 | $this->flushAndClearBatch($iteration, $batchSize); |
|
36 | } |
||
37 | 1 | } catch (Throwable $e) { |
|
38 | 1 | $this->em->rollback(); |
|
39 | |||
40 | 1 | throw $e; |
|
41 | } |
||
42 | |||
43 | 3 | $this->flushAndClearEntityManager(); |
|
44 | 3 | $this->em->commit(); |
|
45 | 3 | } |
|
62 |