FOF30\Database\Installer::openAndVerify PHP Method

openAndVerify() protected method

Opens the schema XML file and return the SimpleXMLElement holding its information. If the file doesn't exist, it is not a schema file or it doesn't match our database driver we return boolean false.
protected openAndVerify ( $fileName ) : false | SimpleXMLElemen\SimpleXMLElement
return false | SimpleXMLElemen\SimpleXMLElement False if it's not a suitable XML schema file
    protected function openAndVerify($fileName)
    {
        $driverType = $this->db->name;
        // Make sure the file exists
        if (!@file_exists($fileName)) {
            return false;
        }
        // Make sure the file is a valid XML document
        try {
            $xml = new SimpleXMLElement($fileName, LIBXML_NONET, true);
        } catch (Exception $e) {
            $xml = null;
            return false;
        }
        // Make sure the file is an XML schema file
        if ($xml->getName() != 'schema') {
            $xml = null;
            return false;
        }
        if (!$xml->meta) {
            $xml = null;
            return false;
        }
        if (!$xml->meta->drivers) {
            $xml = null;
            return false;
        }
        /** @var SimpleXMLElement $drivers */
        $drivers = $xml->meta->drivers;
        foreach ($drivers->children() as $driverTypeTag) {
            $thisDriverType = (string) $driverTypeTag;
            if ($thisDriverType == $driverType) {
                return $xml;
            }
        }
        // Some custom database drivers use a non-standard $name variable. Let try a relaxed match.
        foreach ($drivers->children() as $driverTypeTag) {
            $thisDriverType = (string) $driverTypeTag;
            if (strpos($driverType, $thisDriverType) === 0 || substr($driverType, -strlen($thisDriverType)) == $thisDriverType) {
                return $xml;
            }
        }
        return false;
    }