public function lock(bool $wait = true): bool
    {
        if ($this->fp === null) {
            $this->fp = fopen($this->file, 'r');
        }

        return flock($this->fp, $wait ? LOCK_EX : LOCK_EX | LOCK_NB);
    }