| @@ -27,7 +27,7 @@ discard block | ||
| 27 | 27 |      { | 
| 28 | 28 | $event = Event::fake(); | 
| 29 | 29 | $file = __DIR__ . '/file/lorem-ipsum.pdf'; | 
| 30 | -        if (! is_dir($tmpDir = __DIR__ . '/tmp')) { | |
| 30 | +        if (!is_dir($tmpDir = __DIR__ . '/tmp')) { | |
| 31 | 31 | mkdir($tmpDir, 0755, true); | 
| 32 | 32 | } | 
| 33 | 33 | |
| @@ -42,7 +42,7 @@ discard block | ||
| 42 | 42 |      { | 
| 43 | 43 | $event = Event::fake(); | 
| 44 | 44 | $file = __DIR__ . '/file/lorem-ipsum.pdf'; | 
| 45 | -        if (! is_dir($tmpDir = __DIR__ . '/tmp')) { | |
| 45 | +        if (!is_dir($tmpDir = __DIR__ . '/tmp')) { | |
| 46 | 46 | mkdir($tmpDir, 0755, true); | 
| 47 | 47 | } | 
| 48 | 48 | |
| @@ -8,7 +8,7 @@ | ||
| 8 | 8 |  { | 
| 9 | 9 | public function setUp(): void | 
| 10 | 10 |      { | 
| 11 | - parent::setUp(); | |
| 11 | + parent::setUp(); | |
| 12 | 12 | } | 
| 13 | 13 | |
| 14 | 14 | protected function defineDatabaseMigrations() | 
| @@ -14,7 +14,7 @@ | ||
| 14 | 14 | protected function defineDatabaseMigrations() | 
| 15 | 15 |      { | 
| 16 | 16 | $this->loadLaravelMigrations(); | 
| 17 | - $this->loadMigrationsFrom(__DIR__.'/../migrations'); | |
| 17 | + $this->loadMigrationsFrom(__DIR__ . '/../migrations'); | |
| 18 | 18 | } | 
| 19 | 19 | |
| 20 | 20 | protected function getPackageProviders($app): array | 
| @@ -7,9 +7,9 @@ | ||
| 7 | 7 | class ClamavFileUploadServiceProvider extends ServiceProvider | 
| 8 | 8 |  { | 
| 9 | 9 | |
| 10 | - public const CONFIG = __DIR__.'/config/clamavfileupload.php'; | |
| 11 | - public const LANG = __DIR__.'/lang'; | |
| 12 | - public const DB = __DIR__.'/migrations'; | |
| 10 | + public const CONFIG = __DIR__ . '/config/clamavfileupload.php'; | |
| 11 | + public const LANG = __DIR__ . '/lang'; | |
| 12 | + public const DB = __DIR__ . '/migrations'; | |
| 13 | 13 | |
| 14 | 14 | /** | 
| 15 | 15 | * Bootstrap the application services. | 
| @@ -55,7 +55,7 @@ discard block | ||
| 55 | 55 |          foreach (self::$request->file(self::$input) as $file) { | 
| 56 | 56 |              $disk->putFileAs("", $file, self::$fileName . "_{$i}" . | 
| 57 | 57 | self::getExtension($file)); | 
| 58 | - $i ++; | |
| 58 | + $i++; | |
| 59 | 59 | } | 
| 60 | 60 | |
| 61 | 61 | return true; | 
| @@ -89,7 +89,7 @@ discard block | ||
| 89 | 89 | ->path(self::$uploadPath), '', $file); | 
| 90 | 90 | self::storageDisk()->delete(self::$uploadPath . $file); | 
| 91 | 91 | |
| 92 | - $i ++; | |
| 92 | + $i++; | |
| 93 | 93 | } | 
| 94 | 94 | |
| 95 | 95 | return true; | 
| @@ -186,7 +186,7 @@ discard block | ||
| 186 | 186 | |
| 187 | 187 |          foreach (self::$request->file(self::$input) as $file) { | 
| 188 | 188 | $data[] = self::getFileModelData($file, $i); | 
| 189 | - $i ++; | |
| 189 | + $i++; | |
| 190 | 190 | } | 
| 191 | 191 | |
| 192 | 192 |          if (FileUploadModel::insert($data)) { | 
| @@ -16,7 +16,7 @@ discard block | ||
| 16 | 16 | |
| 17 | 17 | public static function fileUpload(): bool|FileUploadModel|EloquentCollection | 
| 18 | 18 |      { | 
| 19 | -        if(self::$request->file()) { | |
| 19 | +        if (self::$request->file()) { | |
| 20 | 20 | self::storeFiles(); | 
| 21 | 21 | |
| 22 | 22 |              if (!self::areFilesSafe()) { | 
| @@ -90,7 +90,7 @@ discard block | ||
| 90 | 90 | return self::$scanData['status']; | 
| 91 | 91 | } | 
| 92 | 92 | |
| 93 | - $i ++; | |
| 93 | + $i++; | |
| 94 | 94 | } | 
| 95 | 95 | |
| 96 | 96 | FileScanPass::dispatch(self::$scanData); | 
| @@ -16,7 +16,7 @@ discard block | ||
| 16 | 16 | return false; | 
| 17 | 17 | } | 
| 18 | 18 | |
| 19 | - public static function removeFiles(array $files = []): ?bool | |
| 19 | + public static function removeFiles(array $files = []): ?bool | |
| 20 | 20 |      { | 
| 21 | 21 |          foreach ($files as $file) { | 
| 22 | 22 |              $file = str_replace(self::storageDisk()->path('tmp'), '', $file); | 
| @@ -56,7 +56,7 @@ discard block | ||
| 56 | 56 |              $disk->putFileAs("", $file, $tmp); | 
| 57 | 57 |              $tmpFiles[] = self::storageDisk()->path("tmp/{$tmp}"); | 
| 58 | 58 | |
| 59 | - $i ++; | |
| 59 | + $i++; | |
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | 62 | return $tmpFiles; | 
| @@ -49,10 +49,10 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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); | 
| @@ -23,7 +23,7 @@ discard block | ||
| 23 | 23 |              Storage::fake(config('clamavfileupload.disk')); | 
| 24 | 24 | |
| 25 | 25 | $file = __DIR__ . '/file/lorem-ipsum.pdf'; | 
| 26 | -            if (! is_dir($tmpDir = __DIR__ . '/tmp')) { | |
| 26 | +            if (!is_dir($tmpDir = __DIR__ . '/tmp')) { | |
| 27 | 27 | mkdir($tmpDir, 0755, true); | 
| 28 | 28 | } | 
| 29 | 29 | |
| @@ -54,7 +54,7 @@ discard block | ||
| 54 | 54 |              Storage::fake(config('clamavfileupload.disk')); | 
| 55 | 55 | |
| 56 | 56 | $file = __DIR__ . '/file/lorem-ipsum.pdf'; | 
| 57 | -            if (! is_dir($tmpDir = __DIR__ . '/tmp')) { | |
| 57 | +            if (!is_dir($tmpDir = __DIR__ . '/tmp')) { | |
| 58 | 58 | mkdir($tmpDir, 0755, true); | 
| 59 | 59 | } | 
| 60 | 60 | |