@@ -17,7 +17,7 @@  | 
                                                    ||
| 17 | 17 | private static $AVERAGE_COMPRESSION_RATIO = 2;  | 
                                                        
| 18 | 18 | public static $forceTmpFile = false;  | 
                                                        
| 19 | 19 | /** High limit. unit: MBytes.  | 
                                                        
| 20 | - */  | 
                                                        |
| 20 | + */  | 
                                                        |
| 21 | 21 | public static $highLimit = 512;  | 
                                                        
| 22 | 22 | |
| 23 | 23 | private $mode;  | 
                                                        
@@ -11,8 +11,9 @@ discard block  | 
                                                    ||
| 11 | 11 | */  | 
                                                        
| 12 | 12 | public static function registerWrapper()  | 
                                                        
| 13 | 13 |      { | 
                                                        
| 14 | - if (!self::$registered)  | 
                                                        |
| 15 | -            stream_wrapper_register('compress.lzw', __CLASS__); | 
                                                        |
| 14 | +        if (!self::$registered) { | 
                                                        |
| 15 | +                    stream_wrapper_register('compress.lzw', __CLASS__); | 
                                                        |
| 16 | + }  | 
                                                        |
| 16 | 17 | self::$registered = true;  | 
                                                        
| 17 | 18 | }  | 
                                                        
| 18 | 19 | |
@@ -43,12 +44,14 @@ discard block  | 
                                                    ||
| 43 | 44 |      { | 
                                                        
| 44 | 45 | // check for compress & uncompress utility  | 
                                                        
| 45 | 46 | $this->checkBinary();  | 
                                                        
| 46 | - if (self::$installed === false)  | 
                                                        |
| 47 | -            throw new \Exception('compress and uncompress commands are required'); | 
                                                        |
| 47 | +        if (self::$installed === false) { | 
                                                        |
| 48 | +                    throw new \Exception('compress and uncompress commands are required'); | 
                                                        |
| 49 | + }  | 
                                                        |
| 48 | 50 | |
| 49 | 51 | $schema = 'compress.lzw://';  | 
                                                        
| 50 | - if (strncasecmp($schema, $path, strlen($schema)) == 0)  | 
                                                        |
| 51 | - $path = substr($path, strlen($schema));  | 
                                                        |
| 52 | +        if (strncasecmp($schema, $path, strlen($schema)) == 0) { | 
                                                        |
| 53 | + $path = substr($path, strlen($schema));  | 
                                                        |
| 54 | + }  | 
                                                        |
| 52 | 55 | |
| 53 | 56 |          if (file_exists($path)) { | 
                                                        
| 54 | 57 | $this->path = realpath($path);  | 
                                                        
@@ -62,14 +65,16 @@ discard block  | 
                                                    ||
| 62 | 65 | $this->read();  | 
                                                        
| 63 | 66 |              } else { | 
                                                        
| 64 | 67 | $prefix = basename(__FILE__, '.php');  | 
                                                        
| 65 | - if (($tmp = tempnam(sys_get_temp_dir(), $prefix)) === false)  | 
                                                        |
| 66 | - throw new \Exception(__CLASS__.', line '.__LINE__.  | 
                                                        |
| 68 | +                if (($tmp = tempnam(sys_get_temp_dir(), $prefix)) === false) { | 
                                                        |
| 69 | + throw new \Exception(__CLASS__.', line '.__LINE__.  | 
                                                        |
| 67 | 70 | ': Could not create temporary file in '.  | 
                                                        
| 68 | 71 | sys_get_temp_dir());  | 
                                                        
| 69 | - if (($tmp2 = tempnam(sys_get_temp_dir(), $prefix)) === false)  | 
                                                        |
| 70 | - throw new \Exception(__CLASS__.', line '.__LINE__.  | 
                                                        |
| 72 | + }  | 
                                                        |
| 73 | +                if (($tmp2 = tempnam(sys_get_temp_dir(), $prefix)) === false) { | 
                                                        |
| 74 | + throw new \Exception(__CLASS__.', line '.__LINE__.  | 
                                                        |
| 71 | 75 | ': Could not create temporary file in '.  | 
                                                        
| 72 | 76 | sys_get_temp_dir());  | 
                                                        
| 77 | + }  | 
                                                        |
| 73 | 78 | $this->tmp = $tmp;  | 
                                                        
| 74 | 79 | $this->tmp2 = $tmp2;  | 
                                                        
| 75 | 80 | $this->read();  | 
                                                        
@@ -78,14 +83,16 @@ discard block  | 
                                                    ||
| 78 | 83 | $this->path = $path;  | 
                                                        
| 79 | 84 |              if (self::$forceTmpFile) { | 
                                                        
| 80 | 85 | $prefix = basename(__FILE__, '.php');  | 
                                                        
| 81 | - if (($tmp = tempnam(sys_get_temp_dir(), $prefix)) === false)  | 
                                                        |
| 82 | - throw new \Exception(__CLASS__.', line '.__LINE__.  | 
                                                        |
| 86 | +                if (($tmp = tempnam(sys_get_temp_dir(), $prefix)) === false) { | 
                                                        |
| 87 | + throw new \Exception(__CLASS__.', line '.__LINE__.  | 
                                                        |
| 83 | 88 | ': Could not create temporary file in '.  | 
                                                        
| 84 | 89 | sys_get_temp_dir());  | 
                                                        
| 85 | - if (($tmp2 = tempnam(sys_get_temp_dir(), $prefix)) === false)  | 
                                                        |
| 86 | - throw new \Exception(__CLASS__.', line '.__LINE__.  | 
                                                        |
| 90 | + }  | 
                                                        |
| 91 | +                if (($tmp2 = tempnam(sys_get_temp_dir(), $prefix)) === false) { | 
                                                        |
| 92 | + throw new \Exception(__CLASS__.', line '.__LINE__.  | 
                                                        |
| 87 | 93 | ': Could not create temporary file in '.  | 
                                                        
| 88 | 94 | sys_get_temp_dir());  | 
                                                        
| 95 | + }  | 
                                                        |
| 89 | 96 | $this->tmp = $tmp;  | 
                                                        
| 90 | 97 | $this->tmp2 = $tmp2;  | 
                                                        
| 91 | 98 | $this->pointer = 0;  | 
                                                        
@@ -266,7 +273,9 @@ discard block  | 
                                                    ||
| 266 | 273 | }  | 
                                                        
| 267 | 274 |          if ($this->tmp !== null) { | 
                                                        
| 268 | 275 | unlink($this->tmp);  | 
                                                        
| 269 | - if (file_exists($this->tmp2)) unlink($this->tmp2);  | 
                                                        |
| 276 | +            if (file_exists($this->tmp2)) { | 
                                                        |
| 277 | + unlink($this->tmp2);  | 
                                                        |
| 278 | + }  | 
                                                        |
| 270 | 279 |          } else { | 
                                                        
| 271 | 280 | $this->data = null;  | 
                                                        
| 272 | 281 | }  | 
                                                        
@@ -237,8 +237,8 @@  | 
                                                    ||
| 237 | 237 |                  if ($code == 0 || $code == 2 || is_null($code)) { | 
                                                        
| 238 | 238 | // rewrite original file  | 
                                                        
| 239 | 239 |                      if (rename($this->tmp2, $this->path) !== true) { | 
                                                        
| 240 | - throw new \RuntimeException(__FILE__ . ', line ' . __LINE__ .  | 
                                                        |
| 241 | - ': Could not replace original file ' . $this->path);  | 
                                                        |
| 240 | + throw new \RuntimeException(__FILE__.', line '.__LINE__.  | 
                                                        |
| 241 | + ': Could not replace original file '.$this->path);  | 
                                                        |
| 242 | 242 | }  | 
                                                        
| 243 | 243 |                  } else { | 
                                                        
| 244 | 244 | throw new \RuntimeException(__FILE__.', line '.__LINE__.  | 
                                                        
@@ -10,13 +10,13 @@ discard block  | 
                                                    ||
| 10 | 10 | */  | 
                                                        
| 11 | 11 | public static function getBinaryVersion()  | 
                                                        
| 12 | 12 |      { | 
                                                        
| 13 | - if (method_exists(__CLASS__, 'makeBinary7z'))  | 
                                                        |
| 14 | -            try { | 
                                                        |
| 13 | +        if (method_exists(__CLASS__, 'makeBinary7z')) { | 
                                                        |
| 14 | +                    try { | 
                                                        |
| 15 | 15 | $binary = static::makeBinary7z();  | 
                                                        
| 16 | + }  | 
                                                        |
| 16 | 17 |              } catch (\Exception $e) { | 
                                                        
| 17 | 18 | return false;  | 
                                                        
| 18 | - }  | 
                                                        |
| 19 | -        else { | 
                                                        |
| 19 | +            } else { | 
                                                        |
| 20 | 20 | // some hack for gemorroj/archive7z 4.x version  | 
                                                        
| 21 | 21 |              try { | 
                                                        
| 22 | 22 | $seven_zip = new self(null);  | 
                                                        
@@ -29,8 +29,9 @@ discard block  | 
                                                    ||
| 29 | 29 | |
| 30 | 30 |          $process = new Process([str_replace('\\', '/', $binary)]); | 
                                                        
| 31 | 31 | $result = $process->mustRun()->getOutput();  | 
                                                        
| 32 | -        if (!preg_match('~7-Zip (\([a-z]\) )?(\[[\d]+\] )?(?<version>\d+\.\d+)~i', $result, $version)) | 
                                                        |
| 33 | - return false;  | 
                                                        |
| 32 | +        if (!preg_match('~7-Zip (\([a-z]\) )?(\[[\d]+\] )?(?<version>\d+\.\d+)~i', $result, $version)) { | 
                                                        |
| 33 | + return false;  | 
                                                        |
| 34 | + }  | 
                                                        |
| 34 | 35 | |
| 35 | 36 | return $version['version'];  | 
                                                        
| 36 | 37 | }  | 
                                                        
@@ -203,8 +203,9 @@  | 
                                                    ||
| 203 | 203 | $deleted = 0;  | 
                                                        
| 204 | 204 | |
| 205 | 205 |          foreach ($files as $i => $file) { | 
                                                        
| 206 | - if ($this->tar->delete($file))  | 
                                                        |
| 207 | - $deleted++;  | 
                                                        |
| 206 | +            if ($this->tar->delete($file)) { | 
                                                        |
| 207 | + $deleted++;  | 
                                                        |
| 208 | + }  | 
                                                        |
| 208 | 209 | }  | 
                                                        
| 209 | 210 | |
| 210 | 211 | $this->tar = null;  | 
                                                        
@@ -213,7 +213,7 @@  | 
                                                    ||
| 213 | 213 | */  | 
                                                        
| 214 | 214 | public function getFileStream($fileName)  | 
                                                        
| 215 | 215 |      { | 
                                                        
| 216 | -        return fopen('phar://'.$this->fileName . '/' . $fileName, 'rb'); | 
                                                        |
| 216 | +        return fopen('phar://'.$this->fileName.'/'.$fileName, 'rb'); | 
                                                        |
| 217 | 217 | }  | 
                                                        
| 218 | 218 | |
| 219 | 219 | /**  | 
                                                        
@@ -100,7 +100,9 @@ discard block  | 
                                                    ||
| 100 | 100 |      { | 
                                                        
| 101 | 101 | $information = new ArchiveInformation();  | 
                                                        
| 102 | 102 |          foreach ($this->rar->getEntries() as $i => $entry) { | 
                                                        
| 103 | - if ($entry->isDirectory()) continue;  | 
                                                        |
| 103 | +            if ($entry->isDirectory()) { | 
                                                        |
| 104 | + continue;  | 
                                                        |
| 105 | + }  | 
                                                        |
| 104 | 106 | $information->files[] = $entry->getName();  | 
                                                        
| 105 | 107 | $information->compressedFilesSize += $entry->getPackedSize();  | 
                                                        
| 106 | 108 | $information->uncompressedFilesSize += $entry->getUnpackedSize();  | 
                                                        
@@ -115,7 +117,9 @@ discard block  | 
                                                    ||
| 115 | 117 |      { | 
                                                        
| 116 | 118 | $files = [];  | 
                                                        
| 117 | 119 |          foreach ($this->rar->getEntries() as $i => $entry) { | 
                                                        
| 118 | - if ($entry->isDirectory()) continue;  | 
                                                        |
| 120 | +            if ($entry->isDirectory()) { | 
                                                        |
| 121 | + continue;  | 
                                                        |
| 122 | + }  | 
                                                        |
| 119 | 123 | $files[] = $entry->getName();  | 
                                                        
| 120 | 124 | }  | 
                                                        
| 121 | 125 | return $files;  | 
                                                        
@@ -151,7 +155,9 @@ discard block  | 
                                                    ||
| 151 | 155 | public function getFileContent($fileName)  | 
                                                        
| 152 | 156 |      { | 
                                                        
| 153 | 157 | $entry = $this->rar->getEntry($fileName);  | 
                                                        
| 154 | - if ($entry->isDirectory()) return false;  | 
                                                        |
| 158 | +        if ($entry->isDirectory()) { | 
                                                        |
| 159 | + return false;  | 
                                                        |
| 160 | + }  | 
                                                        |
| 155 | 161 | return stream_get_contents($entry->getStream());  | 
                                                        
| 156 | 162 | }  | 
                                                        
| 157 | 163 | |
@@ -163,7 +169,9 @@ discard block  | 
                                                    ||
| 163 | 169 | public function getFileStream($fileName)  | 
                                                        
| 164 | 170 |      { | 
                                                        
| 165 | 171 | $entry = $this->rar->getEntry($fileName);  | 
                                                        
| 166 | - if ($entry->isDirectory()) return false;  | 
                                                        |
| 172 | +        if ($entry->isDirectory()) { | 
                                                        |
| 173 | + return false;  | 
                                                        |
| 174 | + }  | 
                                                        |
| 167 | 175 | return $entry->getStream();  | 
                                                        
| 168 | 176 | }  | 
                                                        
| 169 | 177 | |
@@ -22,7 +22,7 @@ discard block  | 
                                                    ||
| 22 | 22 | */  | 
                                                        
| 23 | 23 | public static function getDescription()  | 
                                                        
| 24 | 24 |      { | 
                                                        
| 25 | -        return 'adapter for ext-rar' . (self::isInstalled() ? ' (' . phpversion('rar') . ')' : null); | 
                                                        |
| 25 | +        return 'adapter for ext-rar'.(self::isInstalled() ? ' ('.phpversion('rar').')' : null); | 
                                                        |
| 26 | 26 | }  | 
                                                        
| 27 | 27 | |
| 28 | 28 | public static function isInstalled()  | 
                                                        
@@ -35,7 +35,7 @@ discard block  | 
                                                    ||
| 35 | 35 | */  | 
                                                        
| 36 | 36 | public static function getInstallationInstruction()  | 
                                                        
| 37 | 37 |      { | 
                                                        
| 38 | - return 'install [rar] extension.' . "\n" . 'Can be installed with pecl: `pecl install rar`';  | 
                                                        |
| 38 | + return 'install [rar] extension.'."\n".'Can be installed with pecl: `pecl install rar`';  | 
                                                        |
| 39 | 39 | }  | 
                                                        
| 40 | 40 | |
| 41 | 41 | /**  | 
                                                        
@@ -15,7 +15,7 @@  | 
                                                    ||
| 15 | 15 |      { | 
                                                        
| 16 | 16 | $fp = fopen($file, 'rb');  | 
                                                        
| 17 | 17 |          if (filesize($file) < 18 || strcmp(fread($fp, 2), "\x1f\x8b")) { | 
                                                        
| 18 | - return false; // Not GZIP format (See RFC 1952)  | 
                                                        |
| 18 | + return false; // Not GZIP format (See RFC 1952)  | 
                                                        |
| 19 | 19 | }  | 
                                                        
| 20 | 20 | $method = fread($fp, 1);  | 
                                                        
| 21 | 21 | $flags = fread($fp, 1);  | 
                                                        
@@ -29,7 +29,7 @@  | 
                                                    ||
| 29 | 29 | }  | 
                                                        
| 30 | 30 | |
| 31 | 31 |          if (!empty($previous_comment = $archive->getComment())) { | 
                                                        
| 32 | -            $output->writeln('Comment "' . $previous_comment . '" replaced', OutputInterface::OUTPUT_RAW); | 
                                                        |
| 32 | +            $output->writeln('Comment "'.$previous_comment.'" replaced', OutputInterface::OUTPUT_RAW); | 
                                                        |
| 33 | 33 |          } else if ($comment === null) { | 
                                                        
| 34 | 34 |              $output->writeln('Comment deleted', OutputInterface::OUTPUT_RAW); | 
                                                        
| 35 | 35 |          } else { | 
                                                        
@@ -48,7 +48,7 @@ discard block  | 
                                                    ||
| 48 | 48 |              if (empty($destination)) { | 
                                                        
| 49 | 49 |                  throw new \LogicException('Source and destination can not be empty'); | 
                                                        
| 50 | 50 | }  | 
                                                        
| 51 | -            $output->writeln('<info>Read ' . $data_size . ' from input</info>'); | 
                                                        |
| 51 | +            $output->writeln('<info>Read '.$data_size.' from input</info>'); | 
                                                        |
| 52 | 52 |          } else { | 
                                                        
| 53 | 53 | $data_size = filesize($source);  | 
                                                        
| 54 | 54 | }  | 
                                                        
@@ -75,9 +75,9 @@ discard block  | 
                                                    ||
| 75 | 75 | }  | 
                                                        
| 76 | 76 |          if ($added_files === 1) { | 
                                                        
| 77 | 77 | $details = $archive->getFileData($destination);  | 
                                                        
| 78 | -            $output->writeln('Added <comment>' . $source . '</comment>(' | 
                                                        |
| 79 | - . implode($this->formatSize($data_size)) . ') as '  | 
                                                        |
| 80 | -                             . $destination . ' (' | 
                                                        |
| 78 | +            $output->writeln('Added <comment>'.$source.'</comment>(' | 
                                                        |
| 79 | + . implode($this->formatSize($data_size)).') as '  | 
                                                        |
| 80 | +                             . $destination.' (' | 
                                                        |
| 81 | 81 | . implode($this->formatSize($details->compressedSize))  | 
                                                        
| 82 | 82 | . ')');  | 
                                                        
| 83 | 83 | }  | 
                                                        
@@ -31,18 +31,18 @@  | 
                                                    ||
| 31 | 31 |          $detect_mimetype = $input->getOption('detect-mimetype'); | 
                                                        
| 32 | 32 | |
| 33 | 33 | $details = $archive->getFileData($file);  | 
                                                        
| 34 | -        $output->writeln('File <info>' . $file . '</info>'); | 
                                                        |
| 34 | +        $output->writeln('File <info>'.$file.'</info>'); | 
                                                        |
| 35 | 35 |          if ($detect_mimetype) { | 
                                                        
| 36 | -            $output->writeln('Mime type: <info>' . $this->getMimeTypeByStream($archive->getFileStream($file)).'</info>'); | 
                                                        |
| 36 | +            $output->writeln('Mime type: <info>'.$this->getMimeTypeByStream($archive->getFileStream($file)).'</info>'); | 
                                                        |
| 37 | 37 | }  | 
                                                        
| 38 | 38 | |
| 39 | 39 |          $output->writeln('Size:'); | 
                                                        
| 40 | -        $output->writeln("\t". 'uncompressed: '.implode(' ', $this->formatSize($details->uncompressedSize, 2))); | 
                                                        |
| 41 | -        $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($details->compressedSize, 2))); | 
                                                        |
| 42 | -        $output->writeln("\t" . 'ratio: <info>' . round($details->uncompressedSize / $details->compressedSize, 6) . '/1 (' . floor($details->compressedSize / $details->uncompressedSize * 100) . '%</info>)'); | 
                                                        |
| 43 | -        $output->writeln('Modificated: ' . $this->formatDate($details->modificationTime)); | 
                                                        |
| 40 | +        $output->writeln("\t".'uncompressed: '.implode(' ', $this->formatSize($details->uncompressedSize, 2))); | 
                                                        |
| 41 | +        $output->writeln("\t".'compressed: '.implode(' ', $this->formatSize($details->compressedSize, 2))); | 
                                                        |
| 42 | +        $output->writeln("\t".'ratio: <info>'.round($details->uncompressedSize / $details->compressedSize, 6).'/1 ('.floor($details->compressedSize / $details->uncompressedSize * 100).'%</info>)'); | 
                                                        |
| 43 | +        $output->writeln('Modificated: '.$this->formatDate($details->modificationTime)); | 
                                                        |
| 44 | 44 | if (!empty($comment = $details->comment))  | 
                                                        
| 45 | -            $output->writeln('Comment: <comment>' . $comment . '</comment>'); | 
                                                        |
| 45 | +            $output->writeln('Comment: <comment>'.$comment.'</comment>'); | 
                                                        |
| 46 | 46 | |
| 47 | 47 |          if (empty($input->getArgument('file'))) { | 
                                                        
| 48 | 48 |              $helper = $this->getHelper('question'); | 
                                                        
@@ -41,8 +41,9 @@  | 
                                                    ||
| 41 | 41 |          $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($details->compressedSize, 2))); | 
                                                        
| 42 | 42 |          $output->writeln("\t" . 'ratio: <info>' . round($details->uncompressedSize / $details->compressedSize, 6) . '/1 (' . floor($details->compressedSize / $details->uncompressedSize * 100) . '%</info>)'); | 
                                                        
| 43 | 43 |          $output->writeln('Modificated: ' . $this->formatDate($details->modificationTime)); | 
                                                        
| 44 | - if (!empty($comment = $details->comment))  | 
                                                        |
| 45 | -            $output->writeln('Comment: <comment>' . $comment . '</comment>'); | 
                                                        |
| 44 | +        if (!empty($comment = $details->comment)) { | 
                                                        |
| 45 | +                    $output->writeln('Comment: <comment>' . $comment . '</comment>'); | 
                                                        |
| 46 | + }  | 
                                                        |
| 46 | 47 | |
| 47 | 48 |          if (empty($input->getArgument('file'))) { | 
                                                        
| 48 | 49 |              $helper = $this->getHelper('question'); | 
                                                        
@@ -88,7 +88,7 @@  | 
                                                    ||
| 88 | 88 | }  | 
                                                        
| 89 | 89 | |
| 90 | 90 |          if ($sort !== null) { | 
                                                        
| 91 | -            usort($rows, function (array $a, array $b) use ($sort_field) { | 
                                                        |
| 91 | +            usort($rows, function(array $a, array $b) use ($sort_field) { | 
                                                        |
| 92 | 92 |                  if ($a[$sort_field] > $b[$sort_field]) { | 
                                                        
| 93 | 93 | return 1;  | 
                                                        
| 94 | 94 | }  |