File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,19 +58,30 @@ public function report(array $resources = []): array
5858 {
5959 $ report = [];
6060
61- $ this ->withCsvStream (function ($ stream ) use (&$ report ) {
62- $ headers = fgetcsv ($ stream );
63- if (! is_array ($ headers ) || count ($ headers ) === 0 ) {
64- return ;
65- }
61+ if (! $ this ->device ->exists ($ this ->filePath )) {
62+ return $ report ;
63+ }
64+
65+ $ file = new \SplFileObject ($ this ->filePath , 'r ' );
66+ $ file ->setFlags (\SplFileObject::READ_CSV | \SplFileObject::SKIP_EMPTY );
6667
67- $ rowCount = 0 ;
68- while (fgetcsv ($ stream ) !== false ) {
69- $ rowCount ++;
68+ if (! $ file ->eof ()) {
69+ $ file ->fgetcsv ();
70+ }
71+
72+ $ rowCount = 0 ;
73+ while (! $ file ->eof ()) {
74+ $ row = $ file ->fgetcsv ();
75+
76+ // check for blank lines
77+ if ($ row === [null ] || $ row === false ) {
78+ continue ;
7079 }
7180
72- $ report [Resource::TYPE_DOCUMENT ] = $ rowCount ;
73- });
81+ $ rowCount ++;
82+ }
83+
84+ $ report [Resource::TYPE_DOCUMENT ] = $ rowCount ;
7485
7586 return $ report ;
7687 }
You can’t perform that action at this time.
0 commit comments