| @@ 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. |
|
| @@ 45-58 (lines=14) @@ | ||
| 42 | * @param Updater $updater |
|
| 43 | * @return void |
|
| 44 | */ |
|
| 45 | public function download(Updater $updater) |
|
| 46 | { |
|
| 47 | /** Switch remote request errors to HttpRequestExceptions */ |
|
| 48 | set_error_handler(array($updater, 'throwHttpRequestException')); |
|
| 49 | $result = humbug_get_contents($this->getPharUrl()); |
|
| 50 | restore_error_handler(); |
|
| 51 | if (false === $result) { |
|
| 52 | throw new HttpRequestException(sprintf( |
|
| 53 | 'Request to URL failed: %s', $this->getPharUrl() |
|
| 54 | )); |
|
| 55 | } |
|
| 56 | ||
| 57 | file_put_contents($updater->getTempPharFile(), $result); |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * Set URL to phar file |
|