Skip to content

Commit

Permalink
[8.x] Add throwIf method in Client Response (#39148)
Browse files Browse the repository at this point in the history
* Add throwIf

* Update Response.php

* Update Response.php

* Update Response.php

* Update Response.php

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
ahmadmayahi and taylorotwell authored Oct 8, 2021
1 parent 2b95dd9 commit 1e4c57c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Illuminate/Http/Client/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,19 @@ public function throw()
return $this;
}

/**
* Throw an exception if a server or client error occurred and the given condition evaluates to true.
*
* @param bool $condition
* @return $this
*
* @throws \Illuminate\Http\Client\RequestException
*/
public function throwIf($condition)
{
return $condition ? $this->throw() : $this;
}

/**
* Determine if the given offset exists.
*
Expand Down

0 comments on commit 1e4c57c

Please sign in to comment.