Skip to content

Commit

Permalink
added methods to read and write file content
Browse files Browse the repository at this point in the history
  • Loading branch information
James Newell committed Jan 4, 2014
1 parent 61fa273 commit 005f95b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/deit/filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,5 +259,36 @@ public function remove($path) {
return $this;
}

/**
* Gets the file content
* @param string $file
* @return string
* @throws
*/
public function getContent($file) {

if (($content = file_get_contents($file)) === false) {
throw new \Exception('Unable to get file content.');
}

return $content;
}

/**
* Sets the file content
* @param string $file
* @param string $content
* @return $this
* @throws
*/
public function setContent($file, $content) {

if (($content = file_put_contents($file, $content)) === false) {
throw new \Exception('Unable to set file content.');
}

return $this;
}

}

0 comments on commit 005f95b

Please sign in to comment.