Fakerino\Configuration\ConfigurationFile\XmlConfigurationFile::toArray PHP Метод

toArray() публичный Метод

public toArray ( )
    public function toArray()
    {
        $xmlString = file_get_contents($this->getConfFilePath());
        $xml = simplexml_load_string($xmlString, 'SimpleXMLElement', LIBXML_NOCDATA);
        $xml2array = $this->xml2array($xml);
        return array($xml->getName() => $xml2array);
    }

Usage Example

 public function testXmlConffile()
 {
     $fileDir = __DIR__ . '/../../Fixtures/';
     $xmlFilePath = $fileDir . 'file.xml';
     $xmlFile = new File($xmlFilePath);
     $xmlConf = new XmlConfigurationFile();
     $xmlConf->loadConfiguration($xmlFile);
     $result = $xmlConf->toArray();
     $this->assertInternalType('array', $result);
     $this->assertNotEmpty($result);
 }
XmlConfigurationFile