diff --git a/composer.json b/composer.json index f9c62fc..bbfbb38 100644 --- a/composer.json +++ b/composer.json @@ -21,14 +21,13 @@ }], "require": { "php": "^8.1", - "cerbero/lazy-json": "^2.0", + "cerbero/json-parser": "^1.1", "guzzlehttp/guzzle": "^7.2", - "illuminate/support": ">=6.20" + "illuminate/collections": ">=8.12" }, "require-dev": { - "illuminate/http": ">=6.20", "mockery/mockery": "^1.3.4", - "orchestra/testbench": ">=7.0", + "orchestra/testbench": ">=6.0", "pestphp/pest": "^2.0", "phpstan/phpstan": "^1.9", "scrutinizer/ocular": "^1.8", diff --git a/src/Concerns/ParsesPages.php b/src/Concerns/ParsesPages.php index f267906..aeb1432 100644 --- a/src/Concerns/ParsesPages.php +++ b/src/Concerns/ParsesPages.php @@ -5,7 +5,7 @@ namespace Cerbero\LazyJsonPages\Concerns; use Cerbero\JsonParser\JsonParser; -use Cerbero\LazyJson\Pointers\DotsConverter; +use Cerbero\LazyJsonPages\Data\Dot; use Generator; use Psr\Http\Message\ResponseInterface; @@ -30,7 +30,7 @@ protected function yieldItemsAndGetKey(ResponseInterface $response, string $key) $pointers = [$this->config->itemsPointer]; if (($value = $response->getHeaderLine($key)) === '') { - $pointers[DotsConverter::toPointer($key)] = fn(mixed $value) => (object) compact('value'); + $pointers[(new Dot($key))->toPointer()] = fn(mixed $value) => (object) compact('value'); } foreach (JsonParser::parse($response)->pointers($pointers) as $item) { diff --git a/src/Data/Dot.php b/src/Data/Dot.php new file mode 100644 index 0000000..6dbab27 --- /dev/null +++ b/src/Data/Dot.php @@ -0,0 +1,27 @@ +dot == '*' ? '' : '/' . str_replace($search, $replace, $this->dot); + } +} diff --git a/src/LazyJsonPages.php b/src/LazyJsonPages.php index 5857214..ad05c4d 100644 --- a/src/LazyJsonPages.php +++ b/src/LazyJsonPages.php @@ -4,8 +4,8 @@ namespace Cerbero\LazyJsonPages; -use Cerbero\LazyJson\Pointers\DotsConverter; use Cerbero\LazyJsonPages\Data\Config; +use Cerbero\LazyJsonPages\Data\Dot; use Cerbero\LazyJsonPages\Paginations\AnyPagination; use Cerbero\LazyJsonPages\Services\ClientFactory; use Cerbero\LazyJsonPages\Sources\AnySource; @@ -281,7 +281,7 @@ public function onError(Closure $callback): self */ public function collect(string $dot = '*'): LazyCollection { - $this->config[Config::OPTION_ITEMS_POINTER] = DotsConverter::toPointer($dot); + $this->config[Config::OPTION_ITEMS_POINTER] = (new Dot($dot))->toPointer(); return new LazyCollection(function () { $client = $this->client->make();