Captioning\File::save PHP Method

save() public method

Saves the file
public save ( string $filename = null, boolean $writeBOM = false )
$filename string
$writeBOM boolean
    public function save($filename = null, $writeBOM = false)
    {
        if ($filename === null) {
            $filename = $this->filename;
        }
        if (trim($this->fileContent) == '') {
            $this->build();
        }
        $file_content = $this->fileContent;
        if (strtolower($this->encoding) != 'utf-8') {
            if ($this->useIconv) {
                $file_content = iconv('UTF-8', $this->encoding, $file_content);
            } else {
                $file_content = mb_convert_encoding($file_content, $this->encoding, 'UTF-8');
            }
        }
        if ($writeBOM) {
            $file_content = "" . $file_content;
        }
        $res = file_put_contents($filename, $file_content);
        if (!$res) {
            throw new \Exception('Unable to save the file.');
        }
    }