AddCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 5
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 10 1
1
<?php
2
/**
3
 * CRM library
4
 * @author Tao <[email protected]>
5
 */
6
namespace Slince\Crm\Command;
7
8
use Slince\Crm\ConfigPath;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
class AddCommand extends Command
14
{
15
    /**
16
     * Command name
17
     * @var string
18
     */
19
    const NAME = 'add';
20
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function configure()
25
    {
26
        $this->setName(static::NAME)
27
            ->setDescription('Add one custom registry')
28
            ->addArgument('registry-name', InputArgument::REQUIRED, 'The registry name')
29
            ->addArgument('registry-url', InputArgument::REQUIRED, 'The registry url');
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function execute(InputInterface $input, OutputInterface $output)
36
    {
37
        $registryName = $input->getArgument('registry-name');
38
        $registryUrl = $input->getArgument('registry-url');
39
        //Add registry & dump to config file
40
        $this->getManager()->addRegistry($registryName, $registryUrl);
41
        $this->getManager()->dumpRepositoriesToFile(ConfigPath::getUserConfigFile());
42
43
        $output->writeln("<info>Add registry [{$registryName}] success</info>");
44
    }
45
}
46