protected function writeToFile($handler, $content, $path = '') { if (($result = @fwrite($handler, $content)) === false || $result < strlen($content)) { throw new IOException('The file "' . $path . '" could not be written to. Check your disk space and file permissions.'); } }