Passed
Push — 1.1.x ( bc52f7...e8e75c )
by f
12:04
created

DeleteFileCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 6 1
A execute() 0 12 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
use wapmorgan\UnifiedArchive\UnifiedArchive;
9
10
class DeleteFileCommand extends BaseFileCommand
11
{
12
    protected static $defaultName = 'file:delete';
13
14
    protected function configure()
15
    {
16
        parent::configure();
17
        $this
18
            ->setDescription('Deletes one file from archive')
19
            ->setHelp('Deletes one file from archive')
20
        ;
21
    }
22
23
    /**
24
     * @throws \wapmorgan\UnifiedArchive\Exceptions\UnsupportedOperationException
25
     * @throws \wapmorgan\UnifiedArchive\Exceptions\ArchiveModificationException
26
     */
27
    public function execute(InputInterface $input, OutputInterface $output)
28
    {
29
        /**
30
         * @var UnifiedArchive $archive
31
         * @var string $file
32
         */
33
        list($archive, $file) = $this->getArchiveAndFile($input, $output);
34
35
        $archive->deleteFiles($file);
36
        $output->writeln('<comment>- file "' . $file . '"</comment>');
37
38
        return 0;
39
    }
40
}
41