| Conditions | 4 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | public function transform($xslt, $xml, $params = []) |
||
| 21 | { |
||
| 22 | $xslDoc = new \DOMDocument(); |
||
| 23 | $xslDoc->load($xslt); |
||
| 24 | |||
| 25 | $xmlDoc = new \DOMDocument(); |
||
| 26 | $xmlDoc->loadXML($xml); |
||
| 27 | |||
| 28 | $processor = new \XSLTProcessor(); |
||
| 29 | |||
| 30 | foreach ($params as $key => $value) { |
||
| 31 | $processor->setParameter('', $key, $value); |
||
| 32 | } |
||
| 33 | |||
| 34 | libxml_use_internal_errors(true); |
||
| 35 | $result = $processor->importStyleSheet($xslDoc); |
||
| 36 | if (!$result) { |
||
| 37 | foreach (libxml_get_errors() as $error) { |
||
| 38 | echo "Libxml error: {$error->message}\n"; |
||
| 39 | } |
||
| 40 | } |
||
| 41 | libxml_use_internal_errors(false); |
||
| 42 | |||
| 43 | return $processor->transformToXml($xmlDoc); |
||
| 44 | } |
||
| 46 | } |