From 0eba98949c25d0287528ecaa33e171ef1aa4cb5e Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 15 Apr 2020 13:43:32 +0800 Subject: [PATCH] Fixed scrutinizer issues --- src/Store/FileStore.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Store/FileStore.php b/src/Store/FileStore.php index 8ece267..8fc37ba 100755 --- a/src/Store/FileStore.php +++ b/src/Store/FileStore.php @@ -4,6 +4,7 @@ namespace PoP\FileStore\Store; +use RuntimeException; use PoP\FileStore\File\AbstractFile; class FileStore implements FileStoreInterface @@ -16,12 +17,17 @@ public function save(AbstractFile $file, $contents) $dir = dirname($filePath); if (!file_exists($dir)) { // Create folder - @mkdir($dir, 0777, true); + if (@mkdir($dir, 0777, true) === false) { + throw new RuntimeException('The directory '.$dir.' could not be created.'); + } } // Open the file, write content and close it $handle = fopen($filePath, "wb"); - $numbytes = fwrite($handle, $contents); + if ($handle === false) { + throw new RuntimeException('The file '.$filePath.' could not be opened.'); + } + fwrite($handle, $contents); fclose($handle); }