| @@ 68-81 (lines=14) @@ | ||
| 65 | * @param Updater $updater |
|
| 66 | * @return void |
|
| 67 | */ |
|
| 68 | public function download(Updater $updater) |
|
| 69 | { |
|
| 70 | /** Switch remote request errors to HttpRequestExceptions */ |
|
| 71 | set_error_handler(array($updater, 'throwHttpRequestException')); |
|
| 72 | $result = humbug_get_contents($this->remoteUrl); |
|
| 73 | restore_error_handler(); |
|
| 74 | if (false === $result) { |
|
| 75 | throw new HttpRequestException(sprintf( |
|
| 76 | 'Request to URL failed: %s', $this->remoteUrl |
|
| 77 | )); |
|
| 78 | } |
|
| 79 | ||
| 80 | file_put_contents($updater->getTempPharFile(), $result); |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * Retrieve the current version available remotely. |
|
| @@ 38-51 (lines=14) @@ | ||
| 35 | * @param Updater $updater |
|
| 36 | * @return void |
|
| 37 | */ |
|
| 38 | public function download(Updater $updater) |
|
| 39 | { |
|
| 40 | /** Switch remote request errors to HttpRequestExceptions */ |
|
| 41 | set_error_handler(array($updater, 'throwHttpRequestException')); |
|
| 42 | $result = humbug_get_contents($this->getPharUrl()); |
|
| 43 | restore_error_handler(); |
|
| 44 | if (false === $result) { |
|
| 45 | throw new HttpRequestException(sprintf( |
|
| 46 | 'Request to URL failed: %s', $this->getPharUrl() |
|
| 47 | )); |
|
| 48 | } |
|
| 49 | ||
| 50 | file_put_contents($updater->getTempPharFile(), $result); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * Set URL to phar file |
|