| @@ 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 |
|
| @@ 72-85 (lines=14) @@ | ||
| 69 | * @param Updater $updater |
|
| 70 | * @return void |
|
| 71 | */ |
|
| 72 | public function download(Updater $updater) |
|
| 73 | { |
|
| 74 | /** Switch remote request errors to HttpRequestExceptions */ |
|
| 75 | set_error_handler(array($updater, 'throwHttpRequestException')); |
|
| 76 | $result = humbug_get_contents($this->remoteUrl); |
|
| 77 | restore_error_handler(); |
|
| 78 | if (false === $result) { |
|
| 79 | throw new HttpRequestException(sprintf( |
|
| 80 | 'Request to URL failed: %s', $this->remoteUrl |
|
| 81 | )); |
|
| 82 | } |
|
| 83 | ||
| 84 | file_put_contents($updater->getTempPharFile(), $result); |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * Retrieve the current version available remotely. |
|