Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 070f489

Browse files
Revert "Send needleFactory to it's own class"
This reverts commit 3bbbaf0.
1 parent eb3651c commit 070f489

File tree

5 files changed

+17
-30
lines changed

5 files changed

+17
-30
lines changed

src/Iterators/JsonFileIterator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ class JsonFileIterator extends JsonIterator
1212

1313
protected $jsonFileHandle;
1414

15-
public function __construct(NeedleFactory $needleFactory, $jsonFileHandle, array $options = null)
15+
public function __construct($jsonFileHandle, array $options = null)
1616
{
1717
$this->jsonFileHandle = $jsonFileHandle;
1818

1919
$jsonString = file_get_contents($jsonFileHandle);
20-
parent::__construct($needleFactory, $jsonString, $options);
20+
parent::__construct($jsonString, $options);
2121
}
2222

2323
public function __destruct()

src/Iterators/JsonFilesIterator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
class JsonFilesIterator extends AppendIterator
1313
{
1414

15-
public function __construct(NeedleFactory $needleFactory, array $jsonFileHandles, array $options = null)
15+
public function __construct($jsonFileHandles, array $options = null)
1616
{
1717
parent::__construct();
1818

1919
foreach ($jsonFileHandles as $jsonFileHandle)
2020
{
21-
$this->append(new JsonFileIterator($needleFactory, $jsonFileHandle, $options));
21+
$this->append(new JsonFileIterator($jsonFileHandle, $options));
2222
}
2323
}
2424

src/Iterators/JsonIterator.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ class JsonIterator implements Iterator
1717
protected $cursorPosition;
1818
protected $nextCursorPosition;
1919

20-
public function __construct(NeedleFactory $needleFactory, $jsonString, array $options = null)
20+
public function __construct($jsonString, array $options = null)
2121
{
2222
$this->jsonString = $jsonString;
2323

2424
$this->setDefaultOptions($options);
25-
$this->needle = $needleFactory->build();
25+
$this->needleFactory($options['firstTopLevelString']);
2626

2727
if ($options['jsonHasSquareBrackets'])
2828
{
@@ -79,6 +79,16 @@ public function valid()
7979
return true;
8080
}
8181

82+
protected function needleFactory($firstTopLevelString = null)
83+
{
84+
$this->needle = ',{';
85+
86+
if ($firstTopLevelString != null)
87+
{
88+
$this->needle .= '"' . $firstTopLevelString . '"';
89+
}
90+
}
91+
8292
protected function getNextCursorPosition()
8393
{
8494
$this->nextCursorPosition = strpos($this->jsonString, $this->needle, $this->cursorPosition);

src/JsonIteratorFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static function buildJsonFileIterator($jsonFileHandle, array $options = n
2424
return new JsonFileIterator($jsonFileHandle, $options);
2525
}
2626

27-
public static function buildJsonFilesIterator(array $jsonFileHandles, array $options = null)
27+
public static function buildJsonFilesIterator($jsonFileHandles, array $options = null)
2828
{
2929
return new JsonFilesIterator($jsonFileHandles, $options);
3030
}

src/NeedleFactory.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)