diff --git a/README.md b/README.md index 885979c..cc1ec29 100644 --- a/README.md +++ b/README.md @@ -108,4 +108,4 @@ etc... - Using Lazy Collections is the preferred method. - Using the queue worker, you can import a several thousand rows at a time without much impact. - Be sure to use "Database Transactions" and "Timeout Detection" to insure safe imports. -- [Article: How to Insert & Update Many at Once](https://medium.com/@danielalvidrez/laravel-query-builder-macros-fe176d34135e) +- [Article: How to Insert & Update Many at Once](https://medium.com/@danielalvidrez/laravel-query-builder-macros-fe176d34135e) \ No newline at end of file diff --git a/composer.json b/composer.json index 9600f98..bc94382 100644 --- a/composer.json +++ b/composer.json @@ -9,13 +9,13 @@ } ], "require": { - "php": "^7.2.5", + "php": "^7.2|^8.0", "illuminate/support": "^6.0|^7.0|^8.0" }, "require-dev": { - "orchestra/testbench": "^4.0", - "phpunit/phpunit": "^8.0", - "nunomaduro/larastan": "^0.4.2" + "orchestra/testbench": "^4.0|^5.0|^6.0", + "phpunit/phpunit": "^8.0|^9.0", + "nunomaduro/larastan": "^0.6" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index 85fc8db..c472786 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -20,9 +20,8 @@ </whitelist> </filter> <logging> - <log type="tap" target="build/report.tap"/> <log type="junit" target="build/report.junit.xml"/> - <log type="coverage-clover" target="clover.xml"/> + <log type="coverage-clover" target="build/clover.xml"/> </logging> <php> <env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsm1"/> diff --git a/src/SimpleCsv.php b/src/SimpleCsv.php index 3fc0e5b..1051fb3 100644 --- a/src/SimpleCsv.php +++ b/src/SimpleCsv.php @@ -6,8 +6,8 @@ /** * The SimpleCsv Service Facade - * @method static \Symfony\Component\HttpFoundation\StreamedResponse download(Collection|LazyCollection|\Iterator|\Generator|array $collection, string $filename) - * @method static void export(Collection|LazyCollection|\Iterator|\Generator|array $collection, string $path) + * @method static \Symfony\Component\HttpFoundation\StreamedResponse download(Collection|LazyCollection|\Iterator|array $collection, string $filename) + * @method static void export(Collection|LazyCollection|\Iterator|array $collection, string $path) * @method static LazyCollection import(string $path) */ class SimpleCsv extends LaravelFacade diff --git a/src/SimpleCsvService.php b/src/SimpleCsvService.php index 89a1bd4..a825de4 100644 --- a/src/SimpleCsvService.php +++ b/src/SimpleCsvService.php @@ -3,11 +3,11 @@ namespace BayAreaWebPro\SimpleCsv; use Iterator; -use Generator; use SplFileObject; use Illuminate\Support\Collection; use Illuminate\Support\LazyCollection; use Symfony\Component\HttpFoundation\StreamedResponse; + class SimpleCsvService { const DELIMITER = ','; @@ -92,7 +92,7 @@ protected function writeLine(array $line): void protected function flattenRow($entry): array { - return method_exists($entry, 'toArray') ? $entry->toArray() : (array)$entry; + return is_object($entry) && method_exists($entry, 'toArray') ? $entry->toArray() : (array)$entry; } protected function openFileObject(string $path, string $mode = 'r'): void @@ -109,7 +109,6 @@ protected function writeLines($collection): void { if ( !$collection instanceof Iterator && - !$collection instanceof Generator && !$collection instanceof Collection && !$collection instanceof LazyCollection && !is_array($collection)