public function download($url, $targetFilePath = null)
{
if (empty($targetFilePath)) {
$targetFilePath = tempnam(sys_get_temp_dir(), 'phpbrew_');
if ($targetFilePath === false) {
throw new RuntimeException('Fail to create temp file');
}
} else {
if (!file_exists($targetFilePath)) {
touch($targetFilePath);
}
}
if (!is_writable($targetFilePath)) {
throw new \RuntimeException("Target path ({$targetFilePath}) is not writable!");
}
if ($this->process($url, $targetFilePath)) {
$this->logger->debug("{$url} => {$targetFilePath}");
return $targetFilePath;
} else {
return false;
}
}