Skip to content

WIP: Start version 2 with some cleanups #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 2.0.0 - unreleased

### Changed

- Client::getLastRequest returns `null` instead of `false` when on requests have been recorded yet.

## 1.5.0 - 2021-08-25

### Changed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
"dev-master": "2.x-dev"
}
},
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions spec/ClientSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ function it_returns_the_last_request(RequestInterface $request, ResponseInterfac
$this->getLastRequest()->shouldReturn($request);
}

function it_returns_false_when_there_is_no_last_request()
function it_returns_null_when_there_is_no_last_request()
{
$this->getLastRequest()->shouldReturn(false);
$this->getLastRequest()->shouldReturn(null);
}

function it_reset(
Expand Down
10 changes: 5 additions & 5 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function addException(\Exception $exception)
*
* If both a default exception and a default response are set, the exception will be thrown.
*/
public function setDefaultException(\Exception $defaultException = null)
public function setDefaultException(?\Exception $defaultException)
{
if (null !== $defaultException && !$defaultException instanceof Exception) {
@trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($defaultException).' will not be possible anymore in the future', E_USER_DEPRECATED);
Expand All @@ -207,7 +207,7 @@ public function addResponse(ResponseInterface $response)
/**
* Sets the default response to be returned when the list of added exceptions and responses is exhausted.
*/
public function setDefaultResponse(ResponseInterface $defaultResponse = null)
public function setDefaultResponse(?ResponseInterface $defaultResponse)
{
$this->defaultResponse = $defaultResponse;
}
Expand All @@ -217,14 +217,14 @@ public function setDefaultResponse(ResponseInterface $defaultResponse = null)
*
* @return RequestInterface[]
*/
public function getRequests()
public function getRequests(): array
{
return $this->requests;
}

public function getLastRequest()
public function getLastRequest(): ?RequestInterface
{
return end($this->requests);
return end($this->requests) ?: null;
}

public function reset()
Expand Down