public createFileWithContents ( string $parentFolderPath, string $fileName, string $fileContents ) : string | ||
$parentFolderPath | string | The parent folder path where the file is going to be created |
$fileName | string | The name of the file to create |
$fileContents | string | The contents of the file to create |
return | string | Path of the created file |
public function createFileWithContents($parentFolderPath, $fileName, $fileContents)
{
$this->throwIfOperationNotInBaseFolder($parentFolderPath);
$filePath = $parentFolderPath . '/' . $fileName;
$wasCreationSuccessful = file_put_contents($filePath, $fileContents);
if ($wasCreationSuccessful === false) {
throw new IOException("Unable to create file: {$filePath}");
}
return $filePath;
}