Skip to content

Commit

Permalink
PHPDoc Comment, spacing and better index checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Sammyjo20 committed Jun 9, 2024
1 parent 6f01a4d commit 5a66758
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Http/Faking/MockClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,12 @@ public function assertNotSent(string|callable $request): void
PHPUnit::assertTrue($result, 'An unexpected request was sent.');
}


/**
* Assert that given requests were sent in order
*
* @param array<\Closure|class-string<Request>|string> $callbacks
* @return void
*/
public function assertSentInOrder(array $callbacks): void
{
$this->assertSentCount(count($callbacks));
Expand Down Expand Up @@ -320,7 +325,6 @@ protected function checkRequestWasSent(string|callable $request, ?int $index = n
return $this->checkClosureAgainstResponses($request, $index);
}


if (is_string($request)) {
if (class_exists($request) && Helpers::isSubclassOf($request, Request::class)) {
$passed = $this->findResponseByRequest($request, $index) instanceof Response;
Expand Down Expand Up @@ -349,8 +353,9 @@ public function findResponseByRequest(string $request, ?int $index = null): ?Res
return null;
}

if($index) {
if(! is_null($index)) {
$recordedResponse = $this->getRecordedResponses()[$index];

if ($recordedResponse->getPendingRequest()->getRequest() instanceof $request) {
return $recordedResponse;
}
Expand Down Expand Up @@ -380,7 +385,7 @@ public function findResponseByRequestUrl(string $url, ?int $index = null): ?Resp
return null;
}

if($index) {
if(! is_null($index)) {
$response = $this->getRecordedResponses()[$index];
$pendingRequest = $response->getPendingRequest();

Expand Down Expand Up @@ -447,7 +452,7 @@ private function checkClosureAgainstResponses(callable $closure, ?int $index = n
return false;
}

if($index) {
if(! is_null($index)) {
$response = $this->getRecordedResponses()[$index];
$request = $response->getPendingRequest()->getRequest();

Expand Down

0 comments on commit 5a66758

Please sign in to comment.