Passed
Push — master ( f73d2a...b6f14a )
by f
14:52
created

InfoCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 14 3
A configure() 0 6 1
1
<?php
2
3
namespace wapmorgan\UnifiedArchive\Commands;
4
5
use Symfony\Component\Console\Input\InputInterface;
6
use Symfony\Component\Console\Output\OutputInterface;
7
8
class InfoCommand extends BaseArchiveCommand
9
{
10
    protected static $defaultName = 'archive:info';
11
12
    protected function configure()
13
    {
14
        parent::configure();
15
        $this
16
            ->setDescription('Renders archive info')
17
            ->setHelp('Renders archive info.')
18
        ;
19
    }
20
21
    /**
22
     * @throws \Exception
23
     */
24
    public function execute(InputInterface $input, OutputInterface $output)
25
    {
26
        $file = realpath($input->getArgument('archive'));
0 ignored issues
show
Bug introduced by
It seems like $input->getArgument('archive') can also be of type null and string[]; however, parameter $path of realpath() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
        $file = realpath(/** @scrutinizer ignore-type */ $input->getArgument('archive'));
Loading history...
27
        $archive = $this->getArchive($input, $output);
28
29
        $output->writeln('Filename: ' . $file . ' (changed <comment>' . $this->formatDate(filemtime($file)) . '</comment>)');
30
        $output->writeln('Type: <info>' . $archive->getFormat() . '</info>, mime <info>' . $archive->getMimeType() . '</info> (via driver <comment>' . $archive->getDriverType() . '</comment>)');
31
        $output->writeln('Contains: ' . $archive->countFiles() . ' file' . ($archive->countFiles() > 1 ? 's' : null));
32
        $output->writeln('Size:');
33
        $output->writeln("\t". 'uncompressed: '.implode(' ', $this->formatSize($archive->getOriginalSize(), 2)));
34
        $output->writeln("\t" . 'compressed: ' . implode(' ', $this->formatSize($archive->getCompressedSize(), 2)));
35
        $output->writeln("\t" . 'ratio: <info>' . round($archive->getOriginalSize() / $archive->getCompressedSize(), 6) . '/1 (' . floor($archive->getCompressedSize() / $archive->getOriginalSize() * 100) . '%</info>)');
36
        if (!empty($comment = $archive->getComment()))
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $comment is correct as $archive->getComment() targeting wapmorgan\UnifiedArchive...edArchive::getComment() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
37
            $output->writeln('Comment: <comment>' . $comment . '</comment>');
38
    }
39
}
40