ListCommand::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[email protected]>.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\AnthillBundle\Command\Roadmap;
17
18
use Symfony\Component\Console\Command\Command;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Output\OutputInterface;
21
use Veslo\AnthillBundle\Vacancy\AntQueen;
22
23
/**
24
 * Shows all available roadmaps for dung (vacancies) digging
25
 *
26
 * Usage example:
27
 * ```
28
 * bin/console veslo:anthill:roadmap:list
29
 * ```
30
 */
31
class ListCommand extends Command
32
{
33
    /**
34
     * Aggregates all available roadmap services for vacancy parsing
35
     *
36
     * @var AntQueen
37
     */
38
    private $antQueen;
39
40
    /**
41
     * ListCommand constructor.
42
     *
43
     * @param AntQueen    $antQueen Aggregates all available roadmap services for vacancy parsing
44
     * @param string|null $name     The name of the command; passing null means it must be set in configure()
45
     */
46
    public function __construct(AntQueen $antQueen, ?string $name = null)
47
    {
48
        $this->antQueen = $antQueen;
49
50
        parent::__construct($name);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    protected function configure()
57
    {
58
        $this->setDescription('Shows all available roadmaps for dung (vacancies) digging');
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    protected function execute(InputInterface $input, OutputInterface $output)
65
    {
66
        $roadmaps = $this->antQueen->getRoadmaps();
67
        $message  = '';
68
69
        foreach ($roadmaps as $roadmapName => $roadmap) {
70
            $message .= "\n  <info>$roadmapName</info>\n";
71
            $message .= '    Type: ' . get_class($roadmap) . "\n";
72
        }
73
74
        $message .= "\nNew roadmaps can be registered in <comment>roadmaps.yml</comment>";
75
76
        $output->writeln($message);
77
    }
78
}
79