Code Duplication    Length = 35-38 lines in 2 locations

src/Command/InfoCommand.php 1 location

@@ 13-47 (lines=35) @@
10
 * Class UnaliasCommand
11
 * @package Geekish\Crap\Command
12
 */
13
final class InfoCommand extends BaseCommand
14
{
15
    /**
16
     * @inheritDoc
17
     */
18
    protected function configure()
19
    {
20
        $this->setName("info");
21
        $this->setDescription("Get a single alias.");
22
        $this->addArgument("alias", InputArgument::REQUIRED, "Package alias");
23
    }
24
25
    /**
26
     * @inheritDoc
27
     */
28
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30
        $alias = $input->getArgument("alias");
31
32
        if (!$this->helper->hasAlias($alias)) {
33
            $output->writeln(sprintf(
34
                "<success>Alias `%s` does not exist.</success>",
35
                $alias
36
            ));
37
38
            return 1;
39
        }
40
41
        $package = $this->helper->getAlias($alias);
42
43
        $output->writeln(sprintf("Alias `%s` is set to: <comment>%s</comment>", $alias, $package));
44
45
        return 0;
46
    }
47
}
48

src/Command/UnaliasCommand.php 1 location

@@ 13-50 (lines=38) @@
10
 * Class UnaliasCommand
11
 * @package Geekish\Crap\Command
12
 */
13
final class UnaliasCommand extends BaseCommand
14
{
15
    /**
16
     * @inheritDoc
17
     */
18
    protected function configure()
19
    {
20
        $this->setName("unalias");
21
        $this->setDescription("Unset an existing crap alias.");
22
        $this->addArgument("alias", InputArgument::REQUIRED, "Package alias");
23
    }
24
25
    /**
26
     * @inheritDoc
27
     */
28
    protected function execute(InputInterface $input, OutputInterface $output)
29
    {
30
        $alias = $input->getArgument("alias");
31
32
        if ($this->helper->hasAlias($alias)) {
33
            $this->helper->unsetAlias($alias);
34
35
            $output->writeln(sprintf(
36
                "<success>Alias `%s` successfully removed.</success>",
37
                $alias
38
            ));
39
40
            return 0;
41
        }
42
43
        $output->writeln(sprintf(
44
            "<comment>Alias `%s` does not exist.</comment>",
45
            $alias
46
        ));
47
48
        return 1;
49
    }
50
}
51