| Conditions | 2 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | 12 | private function withSoapHeader(RequestInterface $request): RequestInterface |
|
| 32 | { |
||
| 33 | 12 | $request->getBody()->rewind(); |
|
| 34 | |||
| 35 | 12 | $xml = new SimpleXMLElement($request->getBody()->getContents()); |
|
| 36 | |||
| 37 | 12 | $query = '//*[local-name()="Action" and namespace-uri()="http://schemas.xmlsoap.org/ws/2004/08/addressing"]'; |
|
| 38 | 12 | $elements = $xml->xpath($query); |
|
| 39 | |||
| 40 | 12 | if (count($elements) === 0) { |
|
| 41 | 1 | throw new RequestException( |
|
| 42 | 1 | 'Malformed request, missing {http://schemas.xmlsoap.org/ws/2004/08/addressing}Action' |
|
| 43 | ); |
||
| 44 | } |
||
| 45 | |||
| 46 | return $request |
||
| 47 | 11 | ->withAddedHeader('SOAPAction', strval($elements[0])) |
|
| 48 | 11 | ->withAddedHeader('Content-Type', 'text/xml; charset=utf-8'); |
|
| 49 | } |
||
| 50 | } |