File tree Expand file tree Collapse file tree 5 files changed +17
-12
lines changed Expand file tree Collapse file tree 5 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ class AcceptXmlMiddleware implements MiddlewareInterface
15
15
use ErrorTrait;
16
16
17
17
/**
18
- * @param RequestInterface $request
19
- * @param array $options
18
+ * @param RequestInterface $request
19
+ * @param array $options
20
20
* @return CancellablePromiseInterface
21
21
*/
22
22
public function pre (
Original file line number Diff line number Diff line change 1
- <?php declare (strict_types=1 );
1
+ <?php declare (strict_types=1 );
2
2
3
3
namespace ApiClients \Middleware \Xml ;
4
4
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ class XmlDecodeMiddleware implements MiddlewareInterface
19
19
use ErrorTrait;
20
20
21
21
/**
22
- * @param ResponseInterface $response
23
- * @param array $options
22
+ * @param ResponseInterface $response
23
+ * @param array $options
24
24
* @return CancellablePromiseInterface
25
25
*
26
26
* @ThirdLast()
@@ -48,11 +48,13 @@ public function post(
48
48
if ($ body === '' ) {
49
49
$ stream = new BufferStream (0 );
50
50
$ stream ->write ($ body );
51
+
51
52
return resolve ($ response ->withBody ($ stream ));
52
53
}
53
54
54
55
$ xml = XML2Array::createArray ($ body );
55
56
$ body = new XmlStream ($ xml );
57
+
56
58
return resolve ($ response ->withBody ($ body ));
57
59
}
58
60
}
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ class XmlEncodeMiddleware implements MiddlewareInterface
19
19
use ErrorTrait;
20
20
21
21
/**
22
- * @param RequestInterface $request
23
- * @param array $options
22
+ * @param RequestInterface $request
23
+ * @param array $options
24
24
* @return CancellablePromiseInterface
25
25
*
26
26
* @Third()
@@ -38,6 +38,7 @@ public function pre(
38
38
$ xml = (new A2X ($ body ->getParsedContents ()))->asXml ();
39
39
$ body = new BufferStream (strlen ($ xml ));
40
40
$ body ->write ($ xml );
41
+
41
42
return resolve ($ request ->withBody ($ body )->withAddedHeader ('Content-Type ' , 'text/xml ' ));
42
43
}
43
44
}
Original file line number Diff line number Diff line change @@ -26,6 +26,11 @@ public function __construct(array $xml)
26
26
$ this ->bufferStream ->write ($ jsonString );
27
27
}
28
28
29
+ public function __toString ()
30
+ {
31
+ return $ this ->getContents ();
32
+ }
33
+
29
34
/**
30
35
* @return array
31
36
*/
@@ -34,11 +39,6 @@ public function getParsedContents(): array
34
39
return $ this ->xml ;
35
40
}
36
41
37
- public function __toString ()
38
- {
39
- return $ this ->getContents ();
40
- }
41
-
42
42
public function getContents ()
43
43
{
44
44
return $ this ->bufferStream ->getContents ();
@@ -94,6 +94,7 @@ public function tell()
94
94
95
95
/**
96
96
* Reads data from the buffer.
97
+ * @param mixed $length
97
98
*/
98
99
public function read ($ length )
99
100
{
@@ -102,6 +103,7 @@ public function read($length)
102
103
103
104
/**
104
105
* Writes data to the buffer.
106
+ * @param mixed $string
105
107
*/
106
108
public function write ($ string )
107
109
{
You can’t perform that action at this time.
0 commit comments