Passed
Push — master ( 96860e...392c1d )
by f
11:16
created

TestCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 13 2
A configure() 0 7 1
1
<?php
2
3
namespace wapmorgan\UnifiedArchive\Commands;
4
5
use Symfony\Component\Console\Input\InputArgument;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
9
class TestCommand extends BaseArchiveCommand
10
{
11
    protected static $defaultName = 'files:test';
12
13
    protected function configure()
14
    {
15
        parent::configure();
16
        $this
17
            ->setDescription('Tests archive contents')
18
            ->setHelp('Tests archive contents.')
19
            ->addArgument('filter', InputArgument::OPTIONAL, 'Files filter (as for fnmatch). If no * passed in filter, it will be added at the end of filter')
20
        ;
21
    }
22
23
    public function execute(InputInterface $input, OutputInterface $output)
24
    {
25
        $archive = $this->getArchive($input, $output);
26
        $test_result = $archive->test($input->getArgument('filter'));
0 ignored issues
show
Bug introduced by
It seems like $input->getArgument('filter') can also be of type string[]; however, parameter $filter of wapmorgan\UnifiedArchive\UnifiedArchive::test() does only seem to accept null|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
        $test_result = $archive->test(/** @scrutinizer ignore-type */ $input->getArgument('filter'));
Loading history...
27
        if ($test_result === true) {
0 ignored issues
show
introduced by
The condition $test_result === true is always true.
Loading history...
28
            $output->writeln('<info>Archive is ok!</info>');
29
        } else {
30
            $output->writeln('<error>Failed:</error>:');
31
            array_walk($test_result, static function ($file) use ($output) {
32
                $output->writeln('- ' . $file);
33
            });
34
        }
35
        return 0;
36
    }
37
}
38