Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
cerbero90 committed Sep 7, 2024
1 parent de070a9 commit d87aa07
Show file tree
Hide file tree
Showing 14 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
use Cerbero\LazyJsonPages\LazyJsonPages;
use Illuminate\Support\LazyCollection;

(static function() {
(static function () {
LazyCollection::macro('fromJsonPages', [LazyJsonPages::class, 'from']);
})();
4 changes: 2 additions & 2 deletions src/Concerns/SendsAsyncRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function fetchPagesAsynchronously(int $totalPages): Generator
$fromPage = $this->config->firstPage + 1;
$toPage = $this->config->firstPage == 0 ? $totalPages - 1 : $totalPages;

yield from $this->retry(function() use ($request, &$fromPage, $toPage) {
yield from $this->retry(function () use ($request, &$fromPage, $toPage) {
foreach ($this->chunkRequestsBetweenPages($request, $fromPage, $toPage) as $requests) {
yield from $this->pool($requests);
}
Expand Down Expand Up @@ -83,7 +83,7 @@ protected function pool(Generator $requests): Generator
$config = [
'concurrency' => $this->config->async,
'fulfilled' => fn(ResponseInterface $response, int $page) => $this->book->addPage($page, $response),
'rejected' => function(Throwable $e, int $page) use (&$exception) {
'rejected' => function (Throwable $e, int $page) use (&$exception) {
$this->book->addFailedPage($page);
$exception = $e;
},
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/YieldsItemsByCursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function yieldItemsByCursor(Closure $callback): Generator

yield from $generator = $callback($this->source->pullResponse());

yield from $this->retry(function() use ($callback, $request, $generator) {
yield from $this->retry(function () use ($callback, $request, $generator) {
while ($cursor = $this->toPage($generator->getReturn(), onlyNumerics: false)) {
$this->respectRateLimits();

Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/YieldsItemsByLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait YieldsItemsByLength
*/
protected function yieldItemsUntilKey(string $key, ?Closure $callback = null): Generator
{
yield from $this->yieldItemsUntilPage(function(ResponseInterface $response) use ($key, $callback) {
yield from $this->yieldItemsUntilPage(function (ResponseInterface $response) use ($key, $callback) {
yield from $generator = $this->yieldItemsAndGetKey($response, $key);

if (!is_int($page = $this->toPage($generator->getReturn()))) {
Expand Down
3 changes: 1 addition & 2 deletions src/Data/RateLimit.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ final class RateLimit
public function __construct(
public readonly int $requests,
public readonly int $perSeconds,
) {
}
) {}

/**
* Update the requests sent before this rate limit resets.
Expand Down
2 changes: 1 addition & 1 deletion src/LazyJsonPages.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public function collect(string $dot = '*'): LazyCollection
{
$this->config[Config::OPTION_ITEMS_POINTER] = DotsConverter::toPointer($dot);

return new LazyCollection(function() {
return new LazyCollection(function () {
$client = $this->client->make();
$config = new Config(...$this->config);
$source = (new AnySource($this->source))->setClient($client);
Expand Down
4 changes: 1 addition & 3 deletions src/Middleware/Tap.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ public static function once(?Closure $onRequest = null, ?Closure $onResponse = n
/**
* Instantiate the class.
*/
public function __construct(private readonly TapCallbacks $callbacks)
{
}
public function __construct(private readonly TapCallbacks $callbacks) {}

/**
* Handle an HTTP request before and after it is sent.
Expand Down
2 changes: 1 addition & 1 deletion src/Paginations/CursorAwarePagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function matches(): bool
*/
public function getIterator(): Traversable
{
yield from $this->yieldItemsByCursor(function(ResponseInterface $response) {
yield from $this->yieldItemsByCursor(function (ResponseInterface $response) {
yield from $generator = $this->yieldItemsAndGetKey($response, $this->config->cursorKey);

return $generator->getReturn();
Expand Down
2 changes: 1 addition & 1 deletion src/Paginations/LastPageAwarePagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function matches(): bool
*/
public function getIterator(): Traversable
{
yield from $this->yieldItemsUntilKey($this->config->lastPageKey, function(int $page) {
yield from $this->yieldItemsUntilKey($this->config->lastPageKey, function (int $page) {
return $this->config->firstPage === 0 ? $page + 1 : $page;
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/Paginations/LinkHeaderAwarePagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function parseLinkHeader(string $linkHeader, ?string $relation = null)
*/
protected function yieldItemsByLastPage(int $lastPage): Generator
{
yield from $this->yieldItemsUntilPage(function(ResponseInterface $response) use ($lastPage) {
yield from $this->yieldItemsUntilPage(function (ResponseInterface $response) use ($lastPage) {
yield from $this->yieldItemsFrom($response);

return $this->config->firstPage === 0 ? $lastPage + 1 : $lastPage;
Expand All @@ -95,7 +95,7 @@ protected function yieldItemsByLastPage(int $lastPage): Generator
*/
protected function yieldItemsByNextLink(): Generator
{
yield from $this->yieldItemsByCursor(function(ResponseInterface $response) {
yield from $this->yieldItemsByCursor(function (ResponseInterface $response) {
yield from $this->yieldItemsFrom($response);

return $this->parseLinkHeader($response->getHeaderLine('link'), 'next');
Expand Down
2 changes: 1 addition & 1 deletion src/Paginations/TotalItemsAwarePagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function matches(): bool
*/
public function getIterator(): Traversable
{
yield from $this->yieldItemsUntilKey($this->config->totalItemsKey, function(int $totalItems) {
yield from $this->yieldItemsUntilKey($this->config->totalItemsKey, function (int $totalItems) {
return $this->itemsPerPage > 0 ? (int) ceil($totalItems / $this->itemsPerPage) : 0;
});
}
Expand Down
1 change: 0 additions & 1 deletion src/Services/ClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Cerbero\LazyJsonPages\Services;

use Cerbero\LazyJsonPages\Middleware\Tap;
use Cerbero\LazyJsonPages\Services\TapCallbacks;
use Closure;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
Expand Down
2 changes: 1 addition & 1 deletion src/Sources/LaravelClientRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace Cerbero\LazyJsonPages\Sources;

use Illuminate\Http\Client\Request;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Illuminate\Http\Client\Request;

/**
* The Laravel HTTP client source.
Expand Down
2 changes: 1 addition & 1 deletion src/Sources/LaravelClientResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
namespace Cerbero\LazyJsonPages\Sources;

use Cerbero\LazyJsonPages\Exceptions\RequestNotSentException;
use Illuminate\Http\Client\Response;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Illuminate\Http\Client\Response;

/**
* The Laravel HTTP client source.
Expand Down

0 comments on commit d87aa07

Please sign in to comment.