Passed
Push — master ( 3ccc44...cef086 )
by Emmanuel
02:16 queued 15s
created

ConfigExampleCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 43
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 8 1
A configure() 0 9 1
1
<?php
2
/**
3
 * neuralyzer : Data Anonymization Library and CLI Tool
4
 *
5
 * PHP Version 7.1
6
 *
7
 * @author Emmanuel Dyan
8
 * @author Rémi Sauvat
9
 * @copyright 2018 Emmanuel Dyan
10
 *
11
 * @package edyan/neuralyzer
12
 *
13
 * @license GNU General Public License v2.0
14
 *
15
 * @link https://github.com/edyan/neuralyzer
16
 */
17
18
namespace Edyan\Neuralyzer\Console\Commands;
19
20
use Symfony\Component\Console\Command\Command;
21
use Symfony\Component\Console\Input\InputInterface;
22
use Symfony\Component\Console\Input\InputOption;
23
use Symfony\Component\Console\Output\OutputInterface;
24
25
/**
26
 * Command to generate an example config file
27
 */
28
class ConfigExampleCommand extends Command
29
{
30
    /**
31
     * Set the command shortcut to be used in configuration
32
     *
33
     * @var string
34
     */
35
    protected $command = 'config:example';
36
37
38
    /**
39
     * Configure the command
40
     *
41
     * @return void
42
     */
43 27
    protected function configure(): void
44
    {
45
        // First command : Test the DB Connexion
46 27
        $this->setName($this->command)
47 27
            ->setDescription(
48 27
                'Generate an example configuration for the Anonymizer'
49 27
            )->setHelp(
50 27
                'This command will take all default values from the config validation' . PHP_EOL .
51 27
                "Usage: neuralyzer <info>{$this->command}</info>"
52
            );
53 27
    }
54
55
    /**
56
     * Execute the command
57
     *
58
     * @param InputInterface  $input
59
     * @param OutputInterface $output
60
     *
61
     * @return void
62
     */
63 1
    protected function execute(InputInterface $input, OutputInterface $output): void
64
    {
65 1
        $dumper = new \Symfony\Component\Config\Definition\Dumper\YamlReferenceDumper;
66 1
        $config = $dumper->dump(
67 1
            new \Edyan\Neuralyzer\Configuration\ConfigDefinition([])
0 ignored issues
show
Unused Code introduced by
The call to Edyan\Neuralyzer\Configu...finition::__construct() has too many arguments starting with array(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

67
            /** @scrutinizer ignore-call */ 
68
            new \Edyan\Neuralyzer\Configuration\ConfigDefinition([])

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
68
        );
69
70 1
        $output->writeLn($config);
71 1
    }
72
}
73