ListPalettesCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A execute() 0 20 4
1
<?php
2
3
namespace SixtyNine\Cloud\Command;
4
5
use SixtyNine\Cloud\Builder\PalettesBuilder;
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 ListPalettesCommand extends Command
13
{
14
    /** {@inheritdoc} */
15
    protected function configure()
16
    {
17
        $this
18
            ->setName('list:palettes')
19
            ->setDescription('List all available palettes')
20
            ->addOption('palettes-file', null, InputOption::VALUE_OPTIONAL, 'Optional path to the fonts, if omitted, defaults to <base>/fonts')
21
        ;
22
    }
23
24
    /** {@inheritdoc} */
25
    protected function execute(InputInterface $input, OutputInterface $output)
26
    {
27
        $palettesFile = __DIR__ . '/../Resources/palettes.yml';
28
        if ($input->getOption('palettes-file')) {
29
            $palettesFile = $input->getOption('palettes-file');
30
        }
31
        $builder = PalettesBuilder::create()->importPalettes($palettesFile);
32
33
        $output->writeln('Palettes found:');
34
        $palettes = $builder->getPalettes();
35
36
        if (!count($palettes)) {
37
            $output->writeln('  No palette found');
38
            return;
39
        }
40
41
        foreach ($palettes as $palette) {
42
            $output->writeln(sprintf('  - %s', $palette->getName()));
43
        }
44
    }
45
}
46