/** * Add data to output queue * * @param Interpreter\InterpreterInterface $interpreter */ protected function addData(Interpreter\Interpreter $interpreter) { $this->response->setHeader('Content-Disposition', 'attachment; ' . 'filename="' . strtolower($interpreter->getEntity()->getProperty('title')) . '.csv" ' . 'creation-date="' . date(DATE_RFC2822, $interpreter->getTo() / 1000) . '"'); $tuples = $interpreter->processData(function ($tuple) { return array($tuple[0], View::formatNumber($tuple[1]), $tuple[2]); }); $min = $interpreter->getMin(); $max = $interpreter->getMax(); $average = $interpreter->getAverage(); $consumption = $interpreter->getConsumption(); $from = $interpreter->getFrom(); $to = $interpreter->getTo(); echo '# uuid: ' . $interpreter->getEntity()->getUuid() . PHP_EOL; if (isset($from)) { echo '# from: ' . $from . PHP_EOL; } if (isset($to)) { echo '# to: ' . $to . PHP_EOL; } if (isset($min)) { echo '# min: ' . $min[0] . ' => ' . $min[1] . PHP_EOL; } if (isset($max)) { echo '# max: ' . $max[0] . ' => ' . $max[1] . PHP_EOL; } if (isset($average)) { echo '# average: ' . View::formatNumber($average) . PHP_EOL; } if (isset($consumption)) { echo '# consumption: ' . View::formatNumber($consumption) . PHP_EOL; } echo '# rows: ' . $interpreter->getRowCount() . PHP_EOL; foreach ($tuples as $tuple) { echo implode(CSV::DELIMITER, $tuple) . PHP_EOL; } }