DeletePadCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 12 1
A execute() 0 12 2
1
<?php
2
3
namespace EtherpadLite\Console\Command;
4
5
use EtherpadLite\Helper\Pad;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Input\InputOption;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class DeletePadCommand extends Command
13
{
14
    protected function configure()
15
    {
16
        $this->setName('pad:delete')
17
            ->setDescription('Delete a pad')
18
            ->setDefinition(
19
                array(
20
                    new InputArgument('padId', InputArgument::REQUIRED, 'The ID of the Pad'),
21
                    new InputOption('apikey', null, InputOption::VALUE_REQUIRED, 'The API Key of your Etherpad Instance'),
22
                    new InputOption('host', null, InputOption::VALUE_OPTIONAL, 'The HTTP Address of your Etherpad Instance', 'http://localhost:9001')
23
                )
24
            );
25
    }
26
27
    protected function execute(InputInterface $input, OutputInterface $output)
28
    {
29
        if (Pad::deletePad(
30
            $input->getArgument('padId'),
31
            $input->getOption('apikey'),
32
            $input->getOption('host')
33
        )) {
34
            $output->writeln('Pad successfully deleted!');
35
        } else {
36
            $output->writeln('Pad could not deleted!');
37
        }
38
    }
39
}
40