Skip to content

Commit

Permalink
Merge pull request #11 from bayareawebpro/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
bayareawebpro authored Dec 26, 2020
2 parents c92796b + 6042c1a commit eada019
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 1 addition & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
4 changes: 2 additions & 2 deletions src/SimpleCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions src/SimpleCsvService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ',';
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit eada019

Please sign in to comment.