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҃-nL]k?"%4I2G#ax~qЈÇ!q+g !iP*#__gop"o,#۞RhMr]V28"/ +&1 9_mM?ASI<(4c2AՎFiLs ;Ah  ve5o4Te2ܛ+DYoЩ $8b:.Q{!4!f1ېGH"tt; tEƃKP9Y]% J]?9c"#+Fpi 6l[R ()6T:=ʊyQn%'N@L/E*a9Dƈ,aWuEYg&@1 U@UP| FE7^jqź%rT ⟧0, Y:f&[HB(sPue5#A+ J\;Ejm#w` Gtn;ﵾb<_(ȞaٳeΏVFa?Y=[n6vt2i h ׯR&+;r!岲,+ nim6,?MYi rMHFЂPoAuO@IWp&Q;'8V 0}ߦVu;Һe-)?FxzR[zEAw#tCU1Y+kZ|{WE&] `(%1yFG`D_pW>!P2[H@:^,ȺoakMq&F[qS ZQ mvD *4%v\ʱ< |NNTNDMd'lf`Pg$P^+'r?FrU 5&*Jd{ҊO!'cwa!wԄvYٶ{ Yn-ڈ|cI0G!$Z+\OQ0"ĢWx[2 J"ՙ !t4BG6R$R֡ B)꡴*K!kJ|/u4 H`1Fhsz4!f1ېGH"ttR .L` q϶I|:.l7B'JlxBHt]kI艠a8h-l;xPue5#A+h9RiW_?۴\nůz=)"A#Ud1Cx"+;*].y%J:CMF9S,pj#8Bڒɪ;iB}K؀^2$y8xN+0!gWrite($writer, $path, /** @scrutinizer ignore-type */ $callStartTime); if ($this->isCli() === false) { echo 'Download ' . basename($path) . '
'; } } $this->logEndingNotes(); } protected function isDirOrMkdir(string $folder): bool { return \is_dir($folder) || \mkdir($folder); } /** * Returns the temporary directory and make sure it exists. * * @return string */ public function getTemporaryFolder() { $tempFolder = sys_get_temp_dir() . '/phpspreadsheet'; if (!$this->isDirOrMkdir($tempFolder)) { throw new RuntimeException(sprintf('Directory "%s" was not created', $tempFolder)); } return $tempFolder; } /** * Returns the filename that should be used for sample output. * * @param string $filename * @param string $extension */ public function getFilename($filename, $extension = 'xlsx'): string { $originalExtension = pathinfo($filename, PATHINFO_EXTENSION); return $this->getTemporaryFolder() . '/' . str_replace('.' . /** @scrutinizer ignore-type */ $originalExtension, '.' . $extension, basename($filename)); } /** * Return a random temporary file name. * * @param string $extension * * @return string */ public function getTemporaryFilename($extension = 'xlsx') { $temporaryFilename = tempnam($this->getTemporaryFolder(), 'phpspreadsheet-'); if ($temporaryFilename === false) { // @codeCoverageIgnoreStart throw new RuntimeException('tempnam returned false'); // @codeCoverageIgnoreEnd } unlink($temporaryFilename); return $temporaryFilename . '.' . $extension; } public function log(string $message): void { $eol = $this->isCli() ? PHP_EOL : '
'; echo($this->isCli() ? date('H:i:s ') : '') . $message . $eol; } public function renderChart(Chart $chart, string $fileName): void { if ($this->isCli() === true) { return; } Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraphRenderer::class); $fileName = $this->getFilename($fileName, 'png'); try { $chart->render($fileName); $this->log('Rendered image: ' . $fileName); $imageData = file_get_contents($fileName); if ($imageData !== false) { echo '
'; } } catch (Throwable $e) { $this->log('Error rendering chart: ' . $e->getMessage() . PHP_EOL); } } public function titles(string $category, string $functionName, ?string $description = null): void { $this->log(sprintf('%s Functions:', $category)); $description === null ? $this->log(sprintf('Function: %s()', rtrim($functionName, '()'))) : $this->log(sprintf('Function: %s() - %s.', rtrim($functionName, '()'), rtrim($description, '.'))); } public function displayGrid(array $matrix): void { $renderer = new TextGrid($matrix, $this->isCli()); echo $renderer->render(); } public function logCalculationResult( Worksheet $worksheet, string $functionName, string $formulaCell, ?string $descriptionCell = null ): void { if ($descriptionCell !== null) { $this->log($worksheet->getCell($descriptionCell)->getValue()); } $this->log($worksheet->getCell($formulaCell)->getValue()); $this->log(sprintf('%s() Result is ', $functionName) . $worksheet->getCell($formulaCell)->getCalculatedValue()); } /** * Log ending notes. */ public function logEndingNotes(): void { // Do not show execution time for index $this->log('Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . 'MB'); } /** * Log a line about the write operation. * * @param string $path * @param float $callStartTime */ public function logWrite(IWriter $writer, $path, $callStartTime): void { $callEndTime = microtime(true); $callTime = $callEndTime - $callStartTime; $reflection = new ReflectionClass($writer); $format = $reflection->getShortName(); $message = ($this->isCli() === true) ? "Write {$format} format to {$path} in " . sprintf('%.4f', $callTime) . ' seconds' : "Write {$format} format to {$path} in " . sprintf('%.4f', $callTime) . ' seconds'; $this->log($message); } /** * Log a line about the read operation. * * @param string $format * @param string $path * @param float $callStartTime */ public function logRead($format, $path, $callStartTime): void { $callEndTime = microtime(true); $callTime = $callEndTime - $callStartTime; $message = "Read {$format} format from {$path} in " . sprintf('%.4f', $callTime) . ' seconds'; $this->log($message); } }