Conditions | 1 |
Paths | 1 |
Total Lines | 24 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 1 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | 2 | public function getXml() |
|
28 | { |
||
29 | 2 | $now = new Datetime(); |
|
30 | |||
31 | $data = [ |
||
32 | 2 | 'request_id' => $this->getId(), |
|
33 | 2 | 'date' => $now->format('Y-m-d'), |
|
34 | 2 | 'time' => $now->format('H:i:s') |
|
35 | 2 | ]; |
|
36 | |||
37 | 2 | $data += $this->getParams(); |
|
38 | |||
39 | // Create the base XML then add the data. |
||
40 | 2 | $baseXml = '<?xml version="1.0" encoding="UTF-8"?><cw:request xmlns:cw="uri:de.checkweigher"></cw:request>'; |
|
41 | 2 | $xmlElement = new SimpleXMLElement($baseXml); |
|
42 | |||
43 | 2 | $xmlConverter = new XmlConverter(); |
|
44 | 2 | $xmlConverter->addArrayAsChildren($data, $xmlElement); |
|
45 | |||
46 | 2 | $xmlContents = $xmlElement->asXML(); |
|
47 | |||
48 | 2 | $header = sprintf("\r\n<(len)>%07d</(len)>\r\n", strlen($xmlContents)); |
|
49 | |||
50 | 2 | return $header.$xmlContents; |
|
51 | } |
||
53 |