From d90fb25a5b3515d4c5ee198bf1b16412928885e5 Mon Sep 17 00:00:00 2001 From: Dariel Ramos Date: Mon, 23 Oct 2023 15:36:43 -0400 Subject: [PATCH] fix quality check --- src/Exportable.php | 18 ++++++++++-------- src/Facades/FastExcel.php | 15 ++++++++------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Exportable.php b/src/Exportable.php index e747050..fc6f740 100644 --- a/src/Exportable.php +++ b/src/Exportable.php @@ -3,14 +3,14 @@ namespace Smart145\FastExcel; use Generator; -use Illuminate\Support\Arr; + use Illuminate\Support\Collection; use Illuminate\Support\Str; use InvalidArgumentException; use OpenSpout\Common\Entity\Row; use OpenSpout\Common\Entity\Style\Style; -use OpenSpout\Writer\Common\AbstractOptions; use OpenSpout\Writer\Common\Creator\WriterEntityFactory; +use OpenSpout\Writer\XLSX\Writer; /** * Trait Exportable. @@ -21,7 +21,6 @@ */ trait Exportable { - /** * @var array */ @@ -34,11 +33,11 @@ trait Exportable private $rows_style; /** - * @param AbstractOptions $options + * @param \OpenSpout\Reader\ReaderInterface|\OpenSpout\Writer\WriterInterface $reader_or_writer * * @return mixed */ - abstract protected function setOptions(&$options); + abstract protected function setOptions(&$reader_or_writer); /** * @param string $path @@ -59,7 +58,7 @@ public function export($path, callable $callback = null) } /** - * @param $path + * @param $path * @param callable|null $callback * * @throws \OpenSpout\Common\Exception\InvalidArgumentException @@ -74,7 +73,7 @@ public function download($path, callable $callback = null) if (method_exists(response(), 'streamDownload')) { return response()->streamDownload(function () use ($path, $callback) { self::exportOrDownload($path, 'openToBrowser', $callback); - }, $path); + }); } self::exportOrDownload($path, 'openToBrowser', $callback); @@ -82,7 +81,7 @@ public function download($path, callable $callback = null) } /** - * @param $path + * @param $path * @param string $function * @param callable|null $callback * @@ -197,6 +196,7 @@ private function writeRowsFromCollection($writer, Collection $collection, ?calla foreach ($removableKeys as $toRemove) { unset($value[$toRemove]); } + return Row::fromValues($value); })->toArray(); if ($this->rows_style) { @@ -346,6 +346,7 @@ public function rowsStyle(Style $style) /** * @param $widths + * * @return $this */ public function setColumnsWidth($widths) @@ -355,3 +356,4 @@ public function setColumnsWidth($widths) return $this; } } + diff --git a/src/Facades/FastExcel.php b/src/Facades/FastExcel.php index 865ab6c..2c86115 100644 --- a/src/Facades/FastExcel.php +++ b/src/Facades/FastExcel.php @@ -7,13 +7,13 @@ /** * Class FastExcel. * - * @method static \Smart145\FastExcel\FastExcel data($data) - * @method static \Illuminate\Support\Collection import($path, callable $callback = null) - * @method static string export($path, callable $callback = null) - * @method static \Illuminate\Support\Collection importSheets($path, callable $callback = null) - * @method static \Smart145\FastExcel\FastExcel configureCsv($delimiter = ',', $enclosure = '"', $encoding = 'UTF-8', $bom = false) - * @method static \Smart145\FastExcel\FastExcel configureReaderUsing(?callable $callback = null) - * @method static \Smart145\FastExcel\FastExcel configureWriterUsing(?callable $callback = null) + * @method static \Smart145\FastExcel\FastExcel data($data) + * @method static \Illuminate\Support\Collection import($path, callable $callback = null) + * @method static string export($path, callable $callback = null) + * @method static \Illuminate\Support\Collection importSheets($path, callable $callback = null) + * @method static \Smart145\FastExcel\FastExcel configureCsv($delimiter = ',', $enclosure = '"', $encoding = 'UTF-8', $bom = false) + * @method static \Smart145\FastExcel\FastExcel configureReaderUsing(?callable $callback = null) + * @method static \Smart145\FastExcel\FastExcel configureWriterUsing(?callable $callback = null) * * @see \Smart145\FastExcel\FastExcel */ @@ -29,3 +29,4 @@ protected static function getFacadeAccessor() return 'fastexcel'; } } +