Skip to content

Commit 9f60d06

Browse files
authored
feat(v1): adding new failed, __toString & toPsrResponse to Response (#22)
1 parent 3118a7e commit 9f60d06

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

.github/release-drafter.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name-template: 'v$NEXT_PATCH_VERSION 🌈'
1+
name-template: 'v$NEXT_PATCH_VERSION'
22
tag-template: 'v$NEXT_PATCH_VERSION'
33
categories:
44
- title: '🚀 Features'
@@ -11,9 +11,14 @@ categories:
1111
- 'bugfix'
1212
- 'bug'
1313
- title: '🧰 Maintenance'
14-
label: 'chore'
14+
labels:
15+
- 'chore'
16+
- 'documentation'
17+
- 'dependencies'
18+
- title: ':boom: BREAKING CHANGE'
19+
label: 'BREAKING CHANGE'
1520
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
1621
template: |
1722
## Changes
1823
19-
$CHANGES
24+
$CHANGES

src/Client/Response.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,24 @@ public static function fromSoapFault(\SoapFault $soapFault)
6767
/**
6868
* Get the full SOAP enveloppe response.
6969
*
70+
* @deprecated removed in v2 and replaced by toPsrResponse
7071
* @return string
7172
*/
7273
public function getResponse(): string
7374
{
7475
return $this->response;
7576
}
7677

78+
/**
79+
* Get the underlying PSR response for the response.
80+
*
81+
* @return \Psr\Http\Message\ResponseInterface
82+
*/
83+
public function toPsrResponse()
84+
{
85+
return $this->response;
86+
}
87+
7788
/**
7889
* Get the JSON decoded body of the response as an object.
7990
*
@@ -133,6 +144,16 @@ public function ok()
133144
return $this->status() === 200;
134145
}
135146

147+
/**
148+
* Determine if the response indicates a client or server error occurred.
149+
*
150+
* @return bool
151+
*/
152+
public function failed()
153+
{
154+
return $this->serverError() || $this->clientError();
155+
}
156+
136157
/**
137158
* Determine if the response was a redirect.
138159
*
@@ -152,7 +173,7 @@ public function redirect()
152173
*/
153174
public function throw()
154175
{
155-
if ($this->serverError() || $this->clientError()) {
176+
if ($this->failed()) {
156177
throw new RequestException($this);
157178
}
158179

@@ -242,6 +263,16 @@ public function offsetUnset($offset)
242263
throw new LogicException('Response data may not be mutated using array access.');
243264
}
244265

266+
/**
267+
* Get the body of the response.
268+
*
269+
* @return string
270+
*/
271+
public function __toString()
272+
{
273+
return $this->body();
274+
}
275+
245276
/**
246277
* Dynamically proxy other methods to the underlying response.
247278
*

0 commit comments

Comments
 (0)