Test Setup Failed
Push — main ( 11ca8f...3ac662 )
by ikechukwu
03:22
created
src/Trait/ClamAV.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
      */
50 50
     private static function socket()
51 51
     {
52
-        if(!empty(config('clamavfileupload.clamd_ip')) && !empty(config('clamavfileupload.clamd_ip'))) {
52
+        if (!empty(config('clamavfileupload.clamd_ip')) && !empty(config('clamavfileupload.clamd_ip'))) {
53 53
             // Attempt to use a network based socket
54 54
             $socket = socket_create(AF_INET, SOCK_STREAM, 0);
55
-            if(socket_connect($socket, config('clamavfileupload.clamd_ip'), config('clamavfileupload.clamd_ip'))) {
55
+            if (socket_connect($socket, config('clamavfileupload.clamd_ip'), config('clamavfileupload.clamd_ip'))) {
56 56
                 self::$message = trans('clamavfileupload::clamav.connected');
57 57
 
58 58
                 return $socket;
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         } else {
61 61
             // By default we just use the local socket
62 62
             $socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
63
-            if(socket_connect($socket, config('clamavfileupload.clamd_sock'))) {
63
+            if (socket_connect($socket, config('clamavfileupload.clamd_sock'))) {
64 64
                 self::$message = trans('clamavfileupload::clamav.socket_connected');
65 65
 
66 66
                 return $socket;
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
     {
86 86
         $ping = self::send("PING");
87 87
 
88
-        if($ping == "PONG") {
88
+        if ($ping == "PONG") {
89 89
             return true;
90 90
         }
91 91
 
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
      */
101 101
     public static function scan($file): bool
102 102
     {
103
-        if(file_exists($file)) {
103
+        if (file_exists($file)) {
104 104
             $scan = self::send("SCAN $file");
105 105
             $scan = substr(strrchr($scan, ":"), 1);
106 106
 
107
-            if($scan !== false) {
107
+            if ($scan !== false) {
108 108
                 self::$message = trim($scan);
109
-                if(self::$message == 'OK') {
109
+                if (self::$message == 'OK') {
110 110
                     return true;
111 111
                 }
112 112
 
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
     public static function scanstream($file): bool
129 129
     {
130 130
         $socket = self::socket();
131
-        if(!$socket) {
131
+        if (!$socket) {
132 132
             self::$message = trans('clamavfileupload::clamav.unable_to_open_socket');
133 133
 
134 134
             return false;
135 135
         }
136 136
 
137
-        if(file_exists($file)) {
137
+        if (file_exists($file)) {
138 138
             if ($scan_fh = fopen($file, 'rb')) {
139 139
                 $chunksize = filesize($file) < 8192 ? filesize($file) : 8192;
140 140
                 $command = "zINSTREAM\0";
@@ -146,16 +146,16 @@  discard block
 block discarded – undo
146 146
                     socket_send($socket, $packet, strlen($packet), 0);
147 147
                 }
148 148
 
149
-                $packet = pack("Nx",0);
149
+                $packet = pack("Nx", 0);
150 150
                 socket_send($socket, $packet, strlen($packet), 0);
151 151
                 socket_recv($socket, $scan, config('clamavfileupload.clamd_sock_len'), 0);
152 152
                 socket_close($socket);
153 153
                 trim($scan);
154 154
                 $scan = substr(strrchr($scan, ":"), 1);
155 155
 
156
-                if($scan !== false) {
156
+                if ($scan !== false) {
157 157
                     self::$message = trim($scan);
158
-                    if(self::$message == 'OK') {
158
+                    if (self::$message == 'OK') {
159 159
 
160 160
                         return true;
161 161
                     }
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
      * In case you need to send any other commands directly.
178 178
      */
179 179
     public static function send($command) {
180
-        if(!empty($command)) {
180
+        if (!empty($command)) {
181 181
             $socket = self::socket();
182
-            if($socket) {
182
+            if ($socket) {
183 183
                 socket_send($socket, $command, strlen($command), 0);
184 184
                 socket_recv($socket, $return, config('clamavfileupload.clamd_sock_len'), 0);
185 185
                 socket_close($socket);
Please login to merge, or discard this patch.