From 756ae6de1dbb6dad15794dcf28c50d8fe0f95daa Mon Sep 17 00:00:00 2001 From: Armand Krijgsman Date: Mon, 28 Jul 2014 09:01:39 +0000 Subject: [PATCH 1/2] Added readFile method --- .gitignore | 1 + Filesystem.php | 18 ++++++++++++++++++ README.md | 3 +++ 3 files changed, 22 insertions(+) diff --git a/.gitignore b/.gitignore index c49a5d8df5..66e7b3a1ec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ vendor/ composer.lock phpunit.xml +.idea diff --git a/Filesystem.php b/Filesystem.php index 7e13571c9e..8495001cc5 100644 --- a/Filesystem.php +++ b/Filesystem.php @@ -478,4 +478,22 @@ private function toIterator($files) return $files; } + + /** + * Read file and return contents. + * + * @param $filename + * + * @return string $filename The file to read. + * + * @throws Exception\IOException + */ + public function readFile($filename) + { + if (false === $source = @file_get_contents($filename)) { + throw new IOException(sprintf('Failed to read "%s" because source file could not be opened for reading.', $filename), 0, null, $filename); + } + + return $source; + } } diff --git a/README.md b/README.md index 7d8a4749ed..ca18b8e1e9 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,9 @@ $filesystem->makePathRelative($endPath, $startPath); $filesystem->mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array()); $filesystem->isAbsolutePath($file); + +$filesystem->readFile($file); + ``` Resources From 05eeda092cccd87fb71c10e1f294055e6f7dd192 Mon Sep 17 00:00:00 2001 From: Armand Krijgsman Date: Mon, 28 Jul 2014 09:06:53 +0000 Subject: [PATCH 2/2] Removed PHPStorm reference from .gitignore for Repo --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 66e7b3a1ec..c49a5d8df5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ vendor/ composer.lock phpunit.xml -.idea