@param string $replacement
@param string $filePath

@return self
423162
public function replaceProjectNamespace(string $replacement, string $filePath): self
    {
        $this->findReplace(
            AbstractGenerator::FIND_PROJECT_NAMESPACE,
            $this->namespaceHelper->tidy($replacement),
            $filePath
        );

        return $this;
    }
881806
public function replaceOneValue($search, $replacement = ''): self
    {
        $array = $this->getArray();
        $key = \array_search($search, $array, true);

        if ($key !== false) {
            $array[$key] = $replacement;
        }

        return static::create(
            $array,
            $this->iteratorClass,
            false
        );
    }
791385
public function setLogFile($filePath)
    {
        if ($this->logFile != $filePath && $this->fp) {
            @fclose($this->fp);
            $this->fp = null;
        }
        $logDir = dirname($filePath);
        if (!file_exists($logDir)) {
            @mkdir($logDir, 0755, true);
        }

        if (!file_exists($logDir)) {
            throw new Exception(sprintf('Can\'t create log directory "%s".', $logDir), 'logger');
        }

        if (!$this->fp = @fopen($filePath, 'a+')) {
            throw new Exception(sprintf('Can\'t create log file "%s".', $filePath), 'logger');
        }

        $this->logFile = $filePath;
        return $this;
    }
982446
protected function traitPostCopy(
        string $filePath
    ): void {
        $this->findAndReplaceHelper->replaceFieldTraitNamespace($this->traitNamespace, $filePath);
        $this->findAndReplaceHelper->replaceFieldInterfaceNamespace($this->interfaceNamespace, $filePath);
        $this->postCopy($filePath);
    }
1293138
public function findReplace(string $find, string $replace)
    {
        $contents = $this->file->getContents();
        $contents = \str_replace($find, $replace, $contents);
        $this->file->setContents($contents);

        return $this;
    }
1195736
protected function setTmpName($filepath)
    {
        $this->tmpName = (string) $filepath;

        $this->stream           = null;
        $this->_c_givenResource = $filepath; # stream will made of this when requested
        return $this;
    }
1346667
public function copy(string $newFolderPath): self
    {
        $newFolderPath = normalize_path($newFolderPath);

        if (!is_dir($newFolderPath)) {
            $newFolder = self::create($newFolderPath);
            if ($this->copyContent($newFolder->getPath())) {
                return $newFolder;
            }
            throw new FolderException('Cannot copy folder to the new folder path ('.$newFolderPath.') for unknown reasons');
        }
        throw new FolderException('Cannot copy the folder, because a folder with the same name and path ('.$newFolderPath.') already exists',
            FolderException::ALREADY_EXIST);
    }
985703
def with_replaced_file(filepath, contents)
      ::Dir.mktmpdir do |temp_dir|
        begin
          temp_path = ::File.join(temp_dir, ::File.basename(filepath))
          ::FileUtils.mkdir_p(::File.dirname(filepath))
          if ::File.file?(filepath)
            ::FileUtils.mv(filepath, temp_path, :force => true)
          end
          ::File.open(filepath, 'w') { |f| f.write(contents) }
          yield
        ensure
          begin
            if ::File.file?(temp_path)
              ::FileUtils.mv(temp_path, filepath, :force => true)
            elsif ::File.file?(filepath)
              ::File.unlink(filepath)
            end
          rescue ::Exception => e
            @logger.note_warning("Failed to restore #{filepath.inspect}: #{e.message}")
          end
        end
      end
    end
974557
public function replaceEntityRepositoriesNamespace(string $replacement, string $filePath): self
    {
        $this->findReplace(
            AbstractGenerator::FIND_ENTITY_REPOSITORIES_NAMESPACE,
            $this->namespaceHelper->tidy($replacement),
            $filePath
        );

        return $this;
    }
244976
public function setFile($filePath = '.gitignore')
    {
        $this->fileContent = array();
        $this->afterLine = null;
        $this->filePath = $filePath;
        $this->checkPermissions();
        $this->parse();
    }
756114
public function setRestorePath($filePath)
    {
        $path = realpath(dirname($filePath));
        if (!file_exists($path)) {
            throw new FilesystemException(sprintf(
                'The restore phar does not exist: %s.', $path
            ));
        }
        if (!is_readable($path)) {
            throw new FilesystemException(sprintf(
                'The restore file is not readable: %s.', $path
            ));
        }
        $this->restorePath = $filePath;
    }
531111
public function replace($column, $target, $replacement)
    {
        $this->queryBuilder->replace($column, $target, $replacement);
        return $this;
    }
815330
public function replaceLanguage($path, $language, $replacement = null)
    {
        $path = $this->stripLanguage($path, $language);
        $path = $this->prependLanguage($path, $replacement);

        return $path;
    }
139359
protected function backupFile($filePath)
    {
        $sourcePath = $filePath;
        $backupPath = $filePath.'.bak';

        if (file_exists($backupPath)) {
            $date = new \DateTime();
            $backupPath = "{$filePath}{$date->getTimestamp()}.bak";
        }

        copy($sourcePath, $backupPath);

        return $backupPath;
    }
350896
public function watermark(string $filePath)
    {
        if (! file_exists($filePath)) {
            throw new FileNotFoundException($filePath);
        }

        $this->addManipulation('watermark', $filePath);

        return $this;
    }
227057
public function addAttachment($filePath) {
        if (!$file = fopen($filePath, 'r')) {
            throw new Exception('Cannot open file "' . $filePath . '"');
        }

        $this->attachments[$filePath] = chunk_split(base64_encode(fread($file, filesize($filePath))));
        return $this;
    }
619165
public static function parse(string $filePath): FilePathInterface
    {
        if (!self::myFilePathParse(
            DIRECTORY_SEPARATOR,
            $filePath,
            function ($p, $d, &$e) {
                return self::myPartValidator($p, $d, $e);
            },
            null,
            $isAbsolute,
            $aboveBaseLevel,
            $drive,
            $directoryParts,
            $filename,
            $error)
        ) {
            throw new FilePathInvalidArgumentException('File path "' . $filePath . '" is invalid: ' . $error);
        }

        return new self($isAbsolute, $aboveBaseLevel, $drive, $directoryParts, $filename);
    }