public function getStatus(): Result
    {
        $result = new Result();
        try {
            $this->connect();
            $connection = DriverManager::getConnection(['pdo' => $this->databaseHandle]);
        } catch (\Exception $exception) {
            $result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
            return $result;
        }
        try {
            $cacheTableExists = $connection->getSchemaManager()->tablesExist([$this->cacheTableName]);
            $tagsTableExists = $connection->getSchemaManager()->tablesExist([$this->tagsTableName]);
        } /** @noinspection PhpRedundantCatchClauseInspection */ catch (DBALException $exception) {
            $result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
            return $result;
        }
        $result->addNotice(new Notice((string)$connection->getDatabase(), null, [], 'Database'));
        $result->addNotice(new Notice((string)$connection->getDriver()->getName(), null, [], 'Driver'));

        if (!$cacheTableExists) {
            $result->addError(new Error('%s (missing)', null, [$this->cacheTableName], 'Table'));
        }
        if (!$tagsTableExists) {
            $result->addError(new Error('%s (missing)', null, [$this->tagsTableName], 'Table'));
        }
        if (!$cacheTableExists || !$tagsTableExists) {
            return $result;
        }
        $fromSchema = $connection->getSchemaManager()->createSchema();
        $schemaDiff = (new Comparator())->compare($fromSchema, $this->getCacheTablesSchema());
        try {
            $statements = $schemaDiff->toSaveSql($connection->getDatabasePlatform());
        } catch (DBALException $exception) {
            $result->addError(new Error($exception->getMessage(), $exception->getCode(), [], 'Connection failed'));
            return $result;
        }
        if ($statements !== []) {
            $result->addError(new Error('The schema of the cache tables is not up-to-date', null, [], 'Table schema'));
            foreach ($statements as $statement) {
                $result->addWarning(new Warning($statement, null, [], 'Required statement'));
            }
        }
        return $result;
    }