Passed
Branch master (671a28)
by Clément
03:29
created
src/Afsy/Component/PageHoover.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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(
Please login to merge, or discard this patch.
src/Afsy/Component/AMQP/AfsyDownloadImageConsumer.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -111,8 +111,7 @@
 block discarded – undo
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
         }
Please login to merge, or discard this patch.