| Conditions | 3 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 32 | protected function parseFile(string $strConfigFile) : array |
||
| 33 | { |
||
| 34 | if (!file_exists($strConfigFile)) { |
||
| 35 | trigger_error('Config File (' . $strConfigFile . ') does not exist!', E_USER_WARNING); |
||
| 36 | } |
||
| 37 | |||
| 38 | // first read XML data into stdclass object using the SimpleXML |
||
| 39 | // to convert this object into associative array by encode it as JSON string and |
||
| 40 | // decode it with the $assoc parameter set to true... |
||
| 41 | try { |
||
| 42 | $oXML = new \SimpleXMLElement($strConfigFile, 0, true); |
||
| 43 | } catch (\Exception $e) { |
||
| 44 | trigger_error('Invalid config file (' . $strConfigFile . '): ' . $e->getMessage(), E_USER_ERROR); |
||
| 45 | } |
||
| 46 | $strJSON = json_encode($oXML); |
||
| 47 | $aXML = json_decode($strJSON, true); |
||
| 48 | |||
| 49 | return $aXML; |
||
| 50 | } |
||
| 52 |