src/GameOfLife/Utils/FileSystem/FileSystemWriter.php
/**
     * Writes text to a file.
     * Will create the file if it doesn't exist
     *
     * @param string $_filePath The file path
     * @param string $_content The file content
     * @param Bool  $_appendToFile Indicates whether the content will be appended to the file
     * @param bool $_overwriteIfExists If set to true, an existing file will be overwritten
     *
     * @throws \Exception The exception when the file already exists and shall not be overwritten in that case
     */
Writes text to a file.
Will create the file if it doesn't exist

@param string $_filePath The file path
@param string $_content The file content
@param Bool  $_appendToFile Indicates whether the content will be appended to the file
@param bool $_overwriteIfExists If set to true, an existing file will be overwritten

@throws \Exception The exception when the file already exists and shall not be overwritten in that case
Writes text to a file . Will create the file if it doesn ' t exist @param string $_filePath The file path @param string $_content The file content @param Bool $_appendToFile Indicates whether the content will be appended to the file @param bool $_overwriteIfExists If set to true an existing file will be overwritten @throws \ Exception The exception when the file already exists and shall not be overwritten in that case
public function writeFile(string $_filePath, string $_content, Bool $_appendToFile = false, bool $_overwriteIfExists = false)
    {
        $filePath = $this->convertSlashes($_filePath);
        $directoryPath = dirname($filePath);
        if (! file_exists($directoryPath)) $this->createDirectory($directoryPath);
        $flags = 0;
        if (file_exists($filePath))
        {
            if ($_appendToFile) $flags = FILE_APPEND;
            elseif (! $_overwriteIfExists) throw new \Exception("The file already exists.");
            else $this->deleteFile($filePath);
        }
        file_put_contents($filePath, $_content, $flags);
        if (! file_exists($filePath))
        {
            throw new \Exception("Unknown error while writing the file \"" . $filePath . "\".");
        }
    }
public function writeFile ( string $ _filePath , string $ _content , Bool $ _appendToFile = false , bool $ _overwriteIfExists = false ) { $ filePath = $ this -> convertSlashes ( $ _filePath ) ; $ directoryPath = dirname ( $ filePath ) ; if ( ! file_exists ( $ directoryPath ) ) $ this -> createDirectory ( $ directoryPath ) ; $ flags = 0 ; if ( file_exists ( $ filePath ) ) { if ( $ _appendToFile ) $ flags = FILE_APPEND ; elseif ( ! $ _overwriteIfExists ) throw new \ Exception ( " The file already exists. " ) ; else $ this -> deleteFile ( $ filePath ) ; } file_put_contents ( $ filePath , $ _content , $ flags ) ; if ( ! file_exists ( $ filePath ) ) { throw new \ Exception ( " Unknown error while writing the file  \" " . $ filePath . " \" . " ) ; } }
Writes text to a file.
Writes text to a file .
// Create directory if it doesn't exist