Exakat\Datastore::__construct PHP Метод

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

public __construct ( Config $config, $create = self::REUSE )
$config Config
    public function __construct(Config $config, $create = self::REUSE)
    {
        $this->sqlitePath = $config->projects_root . '/projects/' . $config->project . '/datastore.sqlite';
        // if project dir isn't created, we are about to create it.
        if (!file_exists($config->projects_root . '/projects/' . $config->project)) {
            return;
        }
        if ($create === self::CREATE) {
            if (file_exists($this->sqlitePath)) {
                unlink($this->sqlitePath);
            }
            // force creation
            self::$sqliteWrite = new \Sqlite3($this->sqlitePath, \SQLITE3_OPEN_READWRITE | \SQLITE3_OPEN_CREATE);
            self::$sqliteWrite->close();
            self::$sqliteWrite = null;
        }
        if (self::$sqliteWrite === null) {
            self::$sqliteWrite = new \Sqlite3($this->sqlitePath, \SQLITE3_OPEN_READWRITE | \SQLITE3_OPEN_CREATE);
            self::$sqliteWrite->busyTimeout(self::TIMEOUT_WRITE);
            // open the read connexion AFTER the write, to have the sqlite databse created
            self::$sqliteRead = new \Sqlite3($this->sqlitePath, \SQLITE3_OPEN_READONLY);
            self::$sqliteWrite->busyTimeout(self::TIMEOUT_READ);
        }
        if ($create === self::CREATE) {
            $this->cleanTable('hash');
            $this->cleanTable('hashAnalyzer');
            $this->cleanTable('analyzed');
            $this->cleanTable('tokenCounts');
            $this->cleanTable('externallibraries');
            $this->cleanTable('ignoredFiles');
            $this->cleanTable('files');
            $this->cleanTable('shortopentag');
            $this->cleanTable('composer');
            $this->cleanTable('configFiles');
            $this->addRow('hash', array('exakat_version' => Exakat::VERSION, 'exakat_build' => Exakat::BUILD, 'datastore_creation' => date('r', time())));
        }
    }