-
Notifications
You must be signed in to change notification settings - Fork 39
cleanup phpdoc and BatchResult interface #73
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
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
namespace Http\Client; | ||
|
||
/** | ||
* Every HTTP Client related Exception should implement this interface | ||
* Every HTTP Client related Exception must implement this interface | ||
* | ||
* @author Márk Sági-Kazár <[email protected]> | ||
*/ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,13 @@ | |
use Http\Client\Exception; | ||
|
||
/** | ||
* This exception is thrown when a batch of requests led to at least one failure. | ||
* This exception is thrown when HttpClient::sendRequests led to at least one failure. | ||
* | ||
* It holds the response/exception pairs and gives access to a BatchResult with the successful responses. | ||
* It gives access to a BatchResult with the request-exception and request-response pairs. | ||
* | ||
* @author Márk Sági-Kazár <[email protected]> | ||
*/ | ||
final class BatchException extends \RuntimeException implements Exception | ||
final class BatchException extends TransferException implements Exception | ||
{ | ||
/** | ||
* @var BatchResult | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
/** | ||
* Thrown when a response was received but has an error status code. | ||
* | ||
* This exception always provides the request and response objects. | ||
* In addition to the request, this exception always provides access to the response object. | ||
* | ||
* @author Márk Sági-Kazár <[email protected]> | ||
*/ | ||
|
@@ -31,11 +31,10 @@ public function __construct( | |
ResponseInterface $response, | ||
\Exception $previous = null | ||
) { | ||
parent::__construct($message, $request, $previous); | ||
|
||
$this->response = $response; | ||
$this->code = $response->getStatusCode(); | ||
|
||
|
||
parent::__construct($message, $request, $previous); | ||
} | ||
|
||
/** | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,9 @@ | |
namespace Http\Client\Exception; | ||
|
||
/** | ||
* Thrown when the request cannot be completed caused by network issues | ||
* Thrown when the request cannot be completed because of network issues. | ||
* | ||
* There is no response object as this exception is thrown when no response has been received. | ||
* | ||
* @author Márk Sági-Kazár <[email protected]> | ||
*/ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,10 @@ | |
use Psr\Http\Message\RequestInterface; | ||
|
||
/** | ||
* Base exception for when a request failed. | ||
* Exception for when a request failed, providing access to the failed request. | ||
* | ||
* This could be due to an invalid request, or one of the extending exceptions | ||
* for network errors or HTTP error responses. | ||
* | ||
* @author Márk Sági-Kazár <[email protected]> | ||
*/ | ||
|
@@ -37,19 +40,4 @@ public function getRequest() | |
{ | ||
return $this->request; | ||
} | ||
|
||
/** | ||
* @param RequestInterface $request | ||
* @param \Exception $e | ||
* | ||
* @return RequestException | ||
*/ | ||
public static function wrapException(RequestInterface $request, \Exception $e) | ||
{ | ||
if (!$e instanceof RequestException) { | ||
$e = new RequestException($e->getMessage(), $request, $e); | ||
} | ||
|
||
return $e; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,6 @@ | |
* | ||
* @author Márk Sági-Kazár <[email protected]> | ||
*/ | ||
class TransferException extends \RuntimeException implements Exception | ||
abstract class TransferException extends \RuntimeException implements Exception | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think we never need to directly instantiate this exception. or do we? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think so. |
||
{ | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or is there a way to spec these things without instantiating the class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add a stub, like in case of BatchRequest trait and test that.