@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $res = $this->client->get($page); |
| 67 | 67 | |
| 68 | 68 | // Check downloaded content |
| 69 | - if($res->getStatusCode() !== 200) { |
|
| 69 | + if ($res->getStatusCode() !== 200) { |
|
| 70 | 70 | return false; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | $pageContent = $res->getBody()->getContents(); |
| 75 | 75 | |
| 76 | 76 | // Save page in downloadFolder |
| 77 | - if(!file_put_contents($saveFile, "\xEF\xBB\xBF".$pageContent)) { |
|
| 77 | + if (!file_put_contents($saveFile, "\xEF\xBB\xBF".$pageContent)) { |
|
| 78 | 78 | // Throw error |
| 79 | 79 | throw new \Exception("Error saving file", 1); |
| 80 | 80 | } |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | $hasHost = filter_var($image, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED); |
| 96 | 96 | |
| 97 | 97 | // Check host |
| 98 | - if(!$hasHost) { $image = $pageParts['dirname'].$image; } |
|
| 98 | + if (!$hasHost) { $image = $pageParts['dirname'].$image; } |
|
| 99 | 99 | |
| 100 | 100 | // Check extension |
| 101 | - if(!in_array($imgExt, array('png', 'jpg', 'jpeg', 'gif'))){ $imgExt = 'png'; } |
|
| 101 | + if (!in_array($imgExt, array('png', 'jpg', 'jpeg', 'gif'))) { $imgExt = 'png'; } |
|
| 102 | 102 | |
| 103 | 103 | // Create image to publish |
| 104 | 104 | $imgToPublish = array( |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $imageToDownload = unserialize($msg->body); |
| 48 | 48 | |
| 49 | 49 | // Download image |
| 50 | - if(!$this->downloadImageTo($imageToDownload['url'], $imageToDownload['savePath'])) { |
|
| 50 | + if (!$this->downloadImageTo($imageToDownload['url'], $imageToDownload['savePath'])) { |
|
| 51 | 51 | // Image should be downloaded again |
| 52 | 52 | return false; |
| 53 | 53 | } |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | $saveStatus = false; |
| 78 | 78 | |
| 79 | 79 | // Check if image already exists |
| 80 | - if(file_exists($saveImagePath)) { |
|
| 80 | + if (file_exists($saveImagePath)) { |
|
| 81 | 81 | echo 'File "'.$saveImagePath.'" already exists'."\n"; |
| 82 | 82 | return true; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // Check if folder already exists |
| 86 | - if(!is_dir($saveImageFolder)) { |
|
| 86 | + if (!is_dir($saveImageFolder)) { |
|
| 87 | 87 | // Initialize |
| 88 | 88 | $createFolderMod = is_int($this->createFolderMod) ? $this->createFolderMod : intval($this->createFolderMod); |
| 89 | 89 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $imageContent = $this->client->get($downloadImagePath); |
| 102 | 102 | |
| 103 | 103 | // Check content |
| 104 | - if(!$imageContent || $imageContent->headers['Status-Code'] == '404') { |
|
| 104 | + if (!$imageContent || $imageContent->headers['Status-Code'] == '404') { |
|
| 105 | 105 | throw new \Exception('Error downloading file "'.$downloadImagePath.'" : returns a void content or a 404 page.', 1); |
| 106 | 106 | } |
| 107 | 107 | |
@@ -111,8 +111,7 @@ |
||
| 111 | 111 | // Log info |
| 112 | 112 | echo 'Image "'.$saveImagePath.'" has been successfully downloaded!'."\n"; |
| 113 | 113 | |
| 114 | - } |
|
| 115 | - catch (\Exception $e) { |
|
| 114 | + } catch (\Exception $e) { |
|
| 116 | 115 | // Log error |
| 117 | 116 | echo '#ERROR# Image "'.$downloadImagePath.'" was not downloaded! '."\n"; |
| 118 | 117 | } |