TestCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 44
rs 10
c 2
b 1
f 0
wmc 4
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 20 1
A execute() 0 18 3
1
<?php
2
3
namespace Ps2alerts\Api\Command;
4
5
use Ps2alerts\Api\Command\BaseCommand;
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 TestCommand extends BaseCommand
13
{
14
    protected $config;
15
16
    protected function configure()
17
    {
18
        parent::configure(); // See BaseCommand.php
19
        $this
20
            ->setName('testCommand')
21
            ->setDescription('Greet someone')
22
            ->addArgument(
23
                'name',
24
                InputArgument::OPTIONAL,
25
                'Who do you want to greet?'
26
            )
27
            ->addOption(
28
                'yell',
29
                null,
30
                InputOption::VALUE_NONE,
31
                'If set, the task will yell in uppercase letters'
32
            );
33
34
        $this->config = $this->container->get('config');
35
    }
36
37
    protected function execute(InputInterface $input, OutputInterface $output)
38
    {
39
        $name = $input->getArgument('name');
40
        if ($name) {
41
            $text = 'Hello '.$name;
42
        } else {
43
            $text = 'Hello';
44
        }
45
46
        if ($input->getOption('yell')) {
47
            $text = strtoupper($text);
48
        }
49
50
        $output->writeln($text);
51
52
        // Should echo #logs unless it's been changed
53
        $output->writeln($this->config['slack_channel']);
54
    }
55
}
56