protected function parseFile($file)
    {
        $this->file    = $file;
        // When running as a PHAR, copy the SQLite database
        // to a temporary file. Required as the SQLite3 driver
        // does not support streams (and it can"t, see #55154).
        if (!strncasecmp(__FILE__, 'phar://', 7)) {
            $this->file = tempnam(
                sys_get_temp_dir(),
                'Wordlists'
            );
            copy($file, $this->file);
        }

        $this->db   = new \PDO('sqlite:' . $this->file);
        $metadata   = $this->db->query(
            'SELECT type, value '.
            'FROM metadata '.
            'ORDER BY type ASC, id ASC'
        );
        foreach ($metadata as $row) {
            if (!array_key_exists($row['type'], $this->metadata)) {
                continue;
            }
            if (is_array($this->metadata[$row['type']])) {
                $this->metadata[$row['type']][] = $row['value'];
            } else {
                $this->metadata[$row['type']] = $row['value'];
            }
        }

        // Try to create a collator for the given locale.
        $this->collator = new \Collator(
            str_replace('-', '_', $this->metadata['locale'])
        );
        // -127 = U_USING_DEFAULT_WARNING
        // -128 = U_USING_FALLBACK_WARNING.
        //    0 = U_ZERO_ERROR (no error).
        if (!in_array(intl_get_error_code(), array(-127, -128, 0))) {
            throw new \Erebot\InvalidValueException(
                "Invalid locale (".$this->metadata['locale']."): ".
                intl_get_error_message()
            );
        }
        // Ignore differences in case, accents and punctuation.
        $this->collator->setStrength(\Collator::PRIMARY);

        $this->countQuery = $this->db->prepare(
            'SELECT COUNT(1) '.
            'FROM words'
        );

        $this->getQuery = $this->db->prepare(
            'SELECT value '.
            'FROM words '.
            'ORDER BY sortkey ASC '.
            'LIMIT 1 OFFSET :offset'
        );

        $this->existsQuery = $this->db->prepare(
            'SELECT value '.
            'FROM words '.
            'WHERE sortkey = :key '.
            'LIMIT 1'
        );
    }