ListFunctions::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace BrainExe\Expression\Command;
4
5
use BrainExe\Annotations\Annotations\Inject;
6
use BrainExe\Core\Annotations\Command as CommandAnnotation;
7
use BrainExe\Expression\Language;
8
use Symfony\Component\Console\Command\Command as SymfonyCommand;
9
use Symfony\Component\Console\Helper\Table;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Output\OutputInterface;
12
13
/**
14
 * @CommandAnnotation("Expression.Command.List")
15
 * @codeCoverageIgnore
16
 */
17
class ListFunctions extends SymfonyCommand
18
{
19
20
    /**
21
     * @var Language
22
     */
23
    private $language;
24
25
    /**
26
     * @Inject("@Expression.Language")
27
     * @param Language $language
28
     */
29
    public function __construct(Language $language)
30
    {
31
        parent::__construct();
32
        $this->language = $language;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    protected function configure()
39
    {
40
        $this->setName('expression:list')
41
             ->setDescription('List all available expression functions');
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    protected function execute(InputInterface $input, OutputInterface $output)
48
    {
49
        $functions = $this->language->getFunctionNames();
50
51
        $table = new Table($output);
52
        $table->setHeaders(['Function']);
53
54
        foreach ($functions as $function) {
55
            $table->addRow([$function]);
56
        }
57
58
        $table->render();
59
    }
60
}
61