isFilePathWriteable($targetFile)) { throw new FileNotWritableException(sprintf( 'Can not merge PDFs. Unable to create target file "%s" .', $targetFile )); } foreach ($sourceFiles as $sourceFile) { if (!is_file($sourceFile)) { throw new FileNotFoundException(sprintf( 'Can not merge PDFs. Source file "%s" does not exist.', $sourceFile )); } } } /** * @param string $filePath * * @return bool */ protected function isFilePathWriteable($filePath) { $result = @fopen($filePath, 'wb'); @unlink($filePath); return $result !== false; } }