Skip to content

Commit e7e904a

Browse files
committed
Merge branch 'hotfix/2.0.1'
2 parents 515bb99 + 336cc1d commit e7e904a

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@
2121
}],
2222
"require": {
2323
"php": "^8.1",
24-
"cerbero/lazy-json": "^2.0",
24+
"cerbero/json-parser": "^1.1",
2525
"guzzlehttp/guzzle": "^7.2",
26-
"illuminate/support": ">=6.20"
26+
"illuminate/collections": ">=8.12"
2727
},
2828
"require-dev": {
29-
"illuminate/http": ">=6.20",
3029
"mockery/mockery": "^1.3.4",
31-
"orchestra/testbench": ">=7.0",
30+
"orchestra/testbench": ">=6.0",
3231
"pestphp/pest": "^2.0",
3332
"phpstan/phpstan": "^1.9",
3433
"scrutinizer/ocular": "^1.8",

src/Concerns/ParsesPages.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace Cerbero\LazyJsonPages\Concerns;
66

77
use Cerbero\JsonParser\JsonParser;
8-
use Cerbero\LazyJson\Pointers\DotsConverter;
8+
use Cerbero\LazyJsonPages\Data\Dot;
99
use Generator;
1010
use Psr\Http\Message\ResponseInterface;
1111

@@ -30,7 +30,7 @@ protected function yieldItemsAndGetKey(ResponseInterface $response, string $key)
3030
$pointers = [$this->config->itemsPointer];
3131

3232
if (($value = $response->getHeaderLine($key)) === '') {
33-
$pointers[DotsConverter::toPointer($key)] = fn(mixed $value) => (object) compact('value');
33+
$pointers[(new Dot($key))->toPointer()] = fn(mixed $value) => (object) compact('value');
3434
}
3535

3636
foreach (JsonParser::parse($response)->pointers($pointers) as $item) {

src/Data/Dot.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Cerbero\LazyJsonPages\Data;
6+
7+
/**
8+
* The dot value object.
9+
*/
10+
final class Dot
11+
{
12+
/**
13+
* Instantiate the class.
14+
*/
15+
public function __construct(public readonly string $dot) {}
16+
17+
/**
18+
* Retrieve the JSON pointer of this dot.
19+
*/
20+
public function toPointer(): string
21+
{
22+
$search = ['~', '/', '.', '*', '\\', '"'];
23+
$replace = ['~0', '~1', '/', '-', '\\\\', '\"'];
24+
25+
return $this->dot == '*' ? '' : '/' . str_replace($search, $replace, $this->dot);
26+
}
27+
}

src/LazyJsonPages.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Cerbero\LazyJsonPages;
66

7-
use Cerbero\LazyJson\Pointers\DotsConverter;
87
use Cerbero\LazyJsonPages\Data\Config;
8+
use Cerbero\LazyJsonPages\Data\Dot;
99
use Cerbero\LazyJsonPages\Paginations\AnyPagination;
1010
use Cerbero\LazyJsonPages\Services\ClientFactory;
1111
use Cerbero\LazyJsonPages\Sources\AnySource;
@@ -281,7 +281,7 @@ public function onError(Closure $callback): self
281281
*/
282282
public function collect(string $dot = '*'): LazyCollection
283283
{
284-
$this->config[Config::OPTION_ITEMS_POINTER] = DotsConverter::toPointer($dot);
284+
$this->config[Config::OPTION_ITEMS_POINTER] = (new Dot($dot))->toPointer();
285285

286286
return new LazyCollection(function () {
287287
$client = $this->client->make();

0 commit comments

Comments
 (0)