OffensiveWordsCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 9 2
A setOffensiveWords() 0 3 1
A execute() 0 12 2
1
<?php
2
3
namespace PhpEarth\Stats\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Helper\Table;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * Class GenerateCommand
12
 */
13
class OffensiveWordsCommand extends Command
14
{
15
    private $offensiveWords = [];
16
17
    /**
18
     * Set offensive words from configuration file
19
     *
20
     * @param $offensiveWords
21
     */
22
    public function setOffensiveWords($offensiveWords)
23
    {
24
        $this->offensiveWords = $offensiveWords;
25
    }
26
27
    /**
28
     * Configures offensive words command for Console component.
29
     */
30
    protected function configure()
31
    {
32
        try {
33
            $this
34
                ->setName('offensive-words')
35
                ->setDescription('Manages offensive words')
36
            ;
37
        } catch (\Exception $e) {
38
            echo $e->getMessage();
39
        }
40
    }
41
42
    /**
43
     * @inheritdoc
44
     */
45
    protected function execute(InputInterface $input, OutputInterface $output)
46
    {
47
        $rows = [];
48
        foreach ($this->offensiveWords as $word) {
49
            $rows[] = [str_rot13($word[0]), $word[1], $word[0]];
50
        }
51
        $table = new Table($output);
52
        $table
53
            ->setHeaders(['String', 'Points', 'ROT13 Transformation'])
54
            ->setRows($rows)
55
        ;
56
        $table->render();
57
    }
58
}
59