public function rename(string $newFileName, bool $withExtension = true, bool $overwrite = true): self
    {
        if (!$withExtension) {
            $newFileName = $newFileName.'.'.$this->getExtension();
        }

        $newFilePath = normalize_path($this->getDirectory().DIRECTORY_SEPARATOR.basename($newFileName));
        if ($newFilePath === $this->getPath() || (($overwrite || !is_file($newFilePath)) && $this->move($newFilePath))) {
            return self::load($newFilePath);
        }
        throw new FileException('Cannot rename the file, because the new file name ('.$newFileName.') already exists',
            FileException::ALREADY_EXIST);
    }