Skip to content

Commit

Permalink
🪄 Code Style Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammyjo20 authored and github-actions[bot] committed Aug 26, 2023
1 parent af7ab4a commit bea0386
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 19 deletions.
11 changes: 3 additions & 8 deletions src/Data/PipeOrder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Saloon\Data;

use Saloon\Enums\Order;
Expand All @@ -8,20 +10,15 @@ class PipeOrder
{
/**
* Constructor
*
* @param \Saloon\Enums\Order $type
*/
public function __construct(
public readonly Order $type,
)
{
) {
//
}

/**
* Run the middleware first
*
* @return self
*/
public static function first(): self
{
Expand All @@ -30,8 +27,6 @@ public static function first(): self

/**
* Run the middleware last
*
* @return self
*/
public static function last(): self
{
Expand Down
2 changes: 2 additions & 0 deletions src/Enums/Order.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Saloon\Enums;

enum Order: string
Expand Down
4 changes: 1 addition & 3 deletions src/Helpers/MiddlewarePipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace Saloon\Helpers;

use Closure;
use Saloon\Data\PipeOrder;
use Saloon\Contracts\Response;
use Saloon\Contracts\FakeResponse;
use Saloon\Contracts\PendingRequest;
use Saloon\Contracts\Pipeline as PipelineContract;
use Saloon\Contracts\MiddlewarePipeline as MiddlewarePipelineContract;
use Saloon\Data\PipeOrder;

class MiddlewarePipeline implements MiddlewarePipelineContract
{
Expand Down Expand Up @@ -52,7 +52,6 @@ public function onRequest(callable $callable, ?string $name = null, ?PipeOrder $
* Do note that this is entirely about our *wrapping* Closure below.
* The provided callable doesn't affect the MiddlewarePipeline.
*/

$this->requestPipeline->pipe(static function (PendingRequest $pendingRequest) use ($callable): PendingRequest {
$result = $callable($pendingRequest);

Expand Down Expand Up @@ -89,7 +88,6 @@ public function onResponse(callable $callable, ?string $name = null, ?PipeOrder
* Do note that this is entirely about our *wrapping* Closure below.
* The provided callable doesn't affect the MiddlewarePipeline.
*/

$this->responsePipeline->pipe(static function (Response $response) use ($callable): Response {
$result = $callable($response);

Expand Down
6 changes: 2 additions & 4 deletions src/Helpers/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
namespace Saloon\Helpers;

use Saloon\Data\Pipe;
use Saloon\Data\PipeOrder;
use Saloon\Enums\Order;
use Saloon\Data\PipeOrder;
use Saloon\Exceptions\DuplicatePipeNameException;
use Saloon\Contracts\Pipeline as PipelineContract;

Expand Down Expand Up @@ -53,15 +53,13 @@ public function process(mixed $payload): mixed

/**
* Sort the pipes based on the "order" classes
*
* @return array
*/
protected function sortPipes(): array
{
$pipes = $this->pipes;

/** @var array<\Saloon\Data\PipeOrder> $pipeNames */
$pipeOrders = array_map(static fn(Pipe $pipe) => $pipe->order, $pipes);
$pipeOrders = array_map(static fn (Pipe $pipe) => $pipe->order, $pipes);

// Now we'll iterate through the pipe orders and if a specific pipe
// requests to be placed at the top - we will move the pipe to the
Expand Down
4 changes: 1 addition & 3 deletions src/Http/Middleware/DetermineMockResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class DetermineMockResponse implements RequestMiddleware
/**
* Guess a mock response
*
* @param \Saloon\Contracts\PendingRequest $pendingRequest
* @return \Saloon\Contracts\PendingRequest|\Saloon\Http\Faking\MockResponse
* @throws \JsonException
* @throws \Saloon\Exceptions\FixtureException
* @throws \Saloon\Exceptions\FixtureMissingException
Expand Down Expand Up @@ -53,7 +51,7 @@ public function __invoke(PendingRequest $pendingRequest): PendingRequest|MockRes
// middleware on the response to record the response.

if (is_null($mockResponse) && $mockObject instanceof Fixture) {
$pendingRequest->middleware()->onResponse(new RecordFixture($mockObject),'recordFixture', PipeOrder::first());
$pendingRequest->middleware()->onResponse(new RecordFixture($mockObject), 'recordFixture', PipeOrder::first());
}

return $pendingRequest;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/MiddlewarePipelineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
declare(strict_types=1);

use Saloon\Data\Pipe;
use Saloon\Data\PipeOrder;
use Saloon\Http\Response;
use Saloon\Data\PipeOrder;
use Saloon\Http\PendingRequest;
use GuzzleHttp\Psr7\HttpFactory;
use Saloon\Http\Faking\MockClient;
Expand Down

0 comments on commit bea0386

Please sign in to comment.