33namespace Http \Client \Utils ;
44
55use Http \Client \Exception ;
6- use Http \Client \BatchResult as BatchResultInterface ;
76use Psr \Http \Message \RequestInterface ;
87use Psr \Http \Message \ResponseInterface ;
98
1211 *
1312 * @author Márk Sági-Kazár <[email protected] > 1413 */
15- final class BatchResult implements BatchResultInterface
14+ final class BatchResult
1615{
1716 /**
1817 * @var \SplObjectStorage
@@ -31,15 +30,19 @@ public function __construct()
3130 }
3231
3332 /**
34- * {@inheritDoc}
33+ * Checks if there are any successful responses at all.
34+ *
35+ * @return boolean
3536 */
3637 public function hasResponses ()
3738 {
3839 return $ this ->responses ->count () > 0 ;
3940 }
4041
4142 /**
42- * {@inheritDoc}
43+ * Returns all successful responses.
44+ *
45+ * @return ResponseInterface[]
4346 */
4447 public function getResponses ()
4548 {
@@ -53,15 +56,25 @@ public function getResponses()
5356 }
5457
5558 /**
56- * {@inheritDoc}
59+ * Checks if there is a successful response for a request.
60+ *
61+ * @param RequestInterface $request
62+ *
63+ * @return boolean
5764 */
5865 public function isSuccessful (RequestInterface $ request )
5966 {
6067 return $ this ->responses ->contains ($ request );
6168 }
6269
6370 /**
64- * {@inheritDoc}
71+ * Returns the response for a successful request.
72+ *
73+ * @param RequestInterface $request
74+ *
75+ * @return ResponseInterface
76+ *
77+ * @throws \UnexpectedValueException If request was not part of the batch or failed.
6578 */
6679 public function getResponseFor (RequestInterface $ request )
6780 {
@@ -73,7 +86,12 @@ public function getResponseFor(RequestInterface $request)
7386 }
7487
7588 /**
76- * {@inheritDoc}
89+ * Adds a response in an immutable way.
90+ *
91+ * @param RequestInterface $request
92+ * @param ResponseInterface $response
93+ *
94+ * @return BatchResult the new BatchResult with this request-response pair added to it.
7795 */
7896 public function addResponse (RequestInterface $ request , ResponseInterface $ response )
7997 {
@@ -84,15 +102,19 @@ public function addResponse(RequestInterface $request, ResponseInterface $respon
84102 }
85103
86104 /**
87- * {@inheritDoc}
105+ * Checks if there are any unsuccessful requests at all.
106+ *
107+ * @return boolean
88108 */
89109 public function hasExceptions ()
90110 {
91111 return $ this ->exceptions ->count () > 0 ;
92112 }
93113
94114 /**
95- * {@inheritDoc}
115+ * Returns all exceptions for the unsuccessful requests.
116+ *
117+ * @return Exception[]
96118 */
97119 public function getExceptions ()
98120 {
@@ -106,15 +128,25 @@ public function getExceptions()
106128 }
107129
108130 /**
109- * {@inheritDoc}
131+ * Checks if there is an exception for a request, meaning the request failed.
132+ *
133+ * @param RequestInterface $request
134+ *
135+ * @return boolean
110136 */
111137 public function isFailed (RequestInterface $ request )
112138 {
113139 return $ this ->exceptions ->contains ($ request );
114140 }
115141
116142 /**
117- * {@inheritDoc}
143+ * Returns the exception for a failed request.
144+ *
145+ * @param RequestInterface $request
146+ *
147+ * @return Exception
148+ *
149+ * @throws \UnexpectedValueException If request was not part of the batch or was successful.
118150 */
119151 public function getExceptionFor (RequestInterface $ request )
120152 {
@@ -126,7 +158,12 @@ public function getExceptionFor(RequestInterface $request)
126158 }
127159
128160 /**
129- * {@inheritDoc}
161+ * Adds an exception in an immutable way.
162+ *
163+ * @param RequestInterface $request
164+ * @param Exception $exception
165+ *
166+ * @return BatchResult the new BatchResult with this request-exception pair added to it.
130167 */
131168 public function addException (RequestInterface $ request , Exception $ exception )
132169 {
0 commit comments