Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
WarehouseSubject | |
100.00% |
13 / 13 |
|
100.00% |
2 / 2 |
6 | |
100.00% |
1 / 1 |
readResponse | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
writeRawReport | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
5 |
1 | <?php |
2 | |
3 | /** |
4 | * @package zmsstatistic |
5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
6 | **/ |
7 | |
8 | namespace BO\Zmsstatistic\Download; |
9 | |
10 | use BO\Zmsentities\Exchange as ReportEntity; |
11 | use BO\Zmsstatistic\Helper\Download; |
12 | use PhpOffice\PhpSpreadsheet\Spreadsheet; |
13 | |
14 | class WarehouseSubject extends Base |
15 | { |
16 | /** |
17 | * @SuppressWarnings(Param) |
18 | * @return String |
19 | */ |
20 | public function readResponse( |
21 | \Psr\Http\Message\RequestInterface $request, |
22 | \Psr\Http\Message\ResponseInterface $response, |
23 | array $args |
24 | ) { |
25 | $title = 'raw_statistic_' . $args['subject']; |
26 | $download = (new Download($request))->setSpreadSheet($title); |
27 | |
28 | $this->writeRawReport($args['reports'][0], $download->getSpreadSheet()); |
29 | |
30 | return $download->writeDownload($response); |
31 | } |
32 | |
33 | protected function writeRawReport(ReportEntity $report, Spreadsheet $spreadsheet) |
34 | { |
35 | $sheet = $spreadsheet->getActiveSheet(); |
36 | $reportData = []; |
37 | foreach ($report->dictionary as $item) { |
38 | $reportData['header'][] = $item['variable']; |
39 | } |
40 | foreach ($report->data as $row => $entry) { |
41 | foreach ($entry as $item) { |
42 | $reportData[$row][] = (is_numeric($item)) ? (string)($item) : $item; |
43 | } |
44 | } |
45 | $sheet->fromArray($reportData, null, 'A' . ($sheet->getHighestRow())); |
46 | return $spreadsheet; |
47 | } |
48 | } |