public function replaceInFile($old, $new, $append = 0) { $contents = $this->previous; $replaceWith = preg_replace("~{$old}\n?~", "{$new}\n", $contents); file_put_contents($this->getPath(), $replaceWith, $append); return $this; }