Total Complexity | 9 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | abstract class BatchHandler extends AbstractProcessingHandler |
||
15 | { |
||
16 | /** |
||
17 | * {@inheritdoc} |
||
18 | */ |
||
19 | 4 | public function handleBatch(array $records): void |
|
20 | { |
||
21 | 4 | $batchRecords = []; |
|
22 | |||
23 | 4 | foreach ($records as $record) { |
|
24 | 4 | if ($record['level'] < $this->level) { |
|
25 | 3 | continue; |
|
26 | } |
||
27 | 3 | $batchRecords[] = $this->processRecord($record); |
|
28 | } |
||
29 | |||
30 | 4 | if (!empty($batchRecords)) { |
|
31 | 3 | $this->send((string) $this->getFormatter()->formatBatch($batchRecords), $batchRecords); |
|
32 | } |
||
33 | 4 | } |
|
34 | |||
35 | /** |
||
36 | * Send a mail with the given content. |
||
37 | * |
||
38 | * @param string $content formatted email body to be sent |
||
39 | * @param array $records the array of log records that formed this content |
||
40 | */ |
||
41 | abstract protected function send($content, array $records); |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | 1 | protected function write(array $record): void |
|
49 | 1 | } |
|
50 | |||
51 | 2 | protected function getHighestRecord(array $records) |
|
63 |