Skip to content

Commit

Permalink
Fixed scrutinizer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
leoloso committed Apr 15, 2020
1 parent 5882955 commit 0eba989
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Store/FileStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace PoP\FileStore\Store;

use RuntimeException;
use PoP\FileStore\File\AbstractFile;

class FileStore implements FileStoreInterface
Expand All @@ -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);
}

Expand Down

0 comments on commit 0eba989

Please sign in to comment.