Skip to content

Commit

Permalink
Merge pull request #41 from ar2r/feature/illuminate_collections
Browse files Browse the repository at this point in the history
tightenco/collect replaced with illuminate/collections
  • Loading branch information
sergiorodenas authored May 20, 2023
2 parents 13ed383 + 5302560 commit 36539a0
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"require": {
"php": ">=7.1",
"ext-xmlreader": "*",
"maxakawizard/json-collection-parser": "^1.1",
"tightenco/collect": "^5.0|^6.0|^7.0|^8.0"
"illuminate/collections": "^8.0|^9.0",
"maxakawizard/json-collection-parser": "^1.1"
},

"require-dev": {
"mockery/mockery": "^0.9.9",
"phpunit/phpunit": "^6.0"
"phpunit/phpunit": "^6.0|^7.0|^8.0|^9.0"
},

"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions src/Parsers/CSVParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
namespace Rodenastyle\StreamParser\Parsers;


use Illuminate\Support\Collection;
use Rodenastyle\StreamParser\Exceptions\IncompleteParseException;
use Rodenastyle\StreamParser\StreamParserInterface;
use Tightenco\Collect\Support\Collection;

class CSVParser implements StreamParserInterface
{
Expand Down Expand Up @@ -100,7 +100,7 @@ private function formatCurrentLineValues(Collection $collection){
private function explodeCollectionValues(Collection $collection){
$collection->transform(function($value){
(new Collection(static::$delimiters))->each(function($delimiter) use (&$value){
if( ! is_array($value) && strpos($value, $delimiter) !== false){
if( ! is_array($value) && $value !== null && strpos($value, $delimiter) !== false){
$value = explode($delimiter, $value);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/Parsers/JSONParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
namespace Rodenastyle\StreamParser\Parsers;


use Illuminate\Support\Collection;
use Rodenastyle\StreamParser\Services\JsonCollectionParser as Parser;
use Rodenastyle\StreamParser\StreamParserInterface;
use Tightenco\Collect\Support\Collection;

class JSONParser implements StreamParserInterface
{
Expand Down
4 changes: 2 additions & 2 deletions src/Parsers/XMLParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
namespace Rodenastyle\StreamParser\Parsers;


use Illuminate\Support\Collection;
use Rodenastyle\StreamParser\Exceptions\IncompleteParseException;
use Rodenastyle\StreamParser\StreamParserInterface;
use Tightenco\Collect\Support\Collection;
use XMLReader;


Expand Down Expand Up @@ -57,7 +57,7 @@ private function searchElement(callable $function)
}
}

private function extractElement(String $elementName, $couldBeAnElementsList = false, int $parentDepth, string $foundInEl = null)
private function extractElement(String $elementName, bool $couldBeAnElementsList, int $parentDepth, string $foundInEl = null)
{
$emptyElement = $this->isEmptyElement($elementName);

Expand Down
4 changes: 2 additions & 2 deletions src/StreamParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
namespace Rodenastyle\StreamParser;


use Illuminate\Support\Collection;
use Rodenastyle\StreamParser\Parsers\CSVParser;
use Rodenastyle\StreamParser\Parsers\JSONParser;
use Rodenastyle\StreamParser\Parsers\XMLParser;
use Rodenastyle\StreamParser\Traits\Facade;
use Tightenco\Collect\Support\Collection;

class StreamParser
{
Expand Down Expand Up @@ -42,4 +42,4 @@ private function json(String $source){
private function csv(String $source){
return (new CSVParser())->from($source);
}
}
}
2 changes: 1 addition & 1 deletion tests/Parsers/CSVParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

namespace Rodenastyle\StreamParser\Test\Parsers;

use Illuminate\Support\Collection;
use PHPUnit\Framework\TestCase;
use Rodenastyle\StreamParser\StreamParser;
use Rodenastyle\StreamParser\Parsers\CSVParser;
use Tightenco\Collect\Support\Collection;

class CSVParserTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Parsers/JSONParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

namespace Rodenastyle\StreamParser\Test\Parsers;

use Illuminate\Support\Collection;
use Rodenastyle\StreamParser\Test\TestCase;
use Rodenastyle\StreamParser\StreamParser;
use Tightenco\Collect\Support\Collection;

class JSONParserTest extends TestCase
{
Expand Down
6 changes: 3 additions & 3 deletions tests/Parsers/TSVParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@

namespace Rodenastyle\StreamParser\Test\Parsers;

use Illuminate\Support\Collection;
use PHPUnit\Framework\TestCase;
use Rodenastyle\StreamParser\StreamParser;
use Rodenastyle\StreamParser\Parsers\CSVParser;
use Tightenco\Collect\Support\Collection;

class TSVParserTest extends TestCase
{
private $stub = __DIR__.DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR."Stubs".DIRECTORY_SEPARATOR."sample.tsv";

protected function setUp() {
protected function setUp(): void {
CSVParser::$fieldDelimiter = "\t";
CSVParser::$skipsEmptyLines = true;
}

protected function tearDown()
protected function tearDown(): void
{
CSVParser::$fieldDelimiter = ",";
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Parsers/XMLParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

namespace Rodenastyle\StreamParser\Test\Parsers;

use Illuminate\Support\Collection;
use Rodenastyle\StreamParser\StreamParser;
use Rodenastyle\StreamParser\Test\Contracts\ElementAttributesManagement;
use Rodenastyle\StreamParser\Test\Contracts\ElementListManagement;
use Rodenastyle\StreamParser\Test\Contracts\ElementDepthManagement;
use Rodenastyle\StreamParser\Test\TestCase;
use Tightenco\Collect\Support\Collection;

class XMLParserTest extends TestCase implements ElementAttributesManagement, ElementListManagement, ElementDepthManagement {

Expand Down

0 comments on commit 36539a0

Please sign in to comment.