Completed
Push — develop ( 8b0772...a0b2b6 )
by Paul
04:54
created

GenerateDefaultCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PhpUnitGen\Console;
4
5
use PhpUnitGen\Configuration\ConfigurationInterface\ConsoleConfigFactoryInterface;
6
use PhpUnitGen\Configuration\ConfigurationInterface\ConsoleConfigInterface;
7
use PhpUnitGen\Configuration\DefaultConsoleConfigFactory;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputInterface;
10
11
/**
12
 * Class GenerateDefaultCommand.
13
 *
14
 * @author     Paul Thébaud <[email protected]>.
15
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
16
 * @license    https://opensource.org/licenses/MIT The MIT license.
17
 * @link       https://github.com/paul-thebaud/phpunit-generator
18
 * @since      Class available since Release 2.0.0.
19
 */
20
class GenerateDefaultCommand extends AbstractGenerateCommand
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    protected function configure()
26
    {
27
        $this->setName("generate-default")
28
            ->setDescription("Generate unit tests skeletons with a default configuration")
29
            ->setHelp("Use it to generate your unit tests skeletons from a default config")
30
            ->addArgument('source-path', InputArgument::REQUIRED, 'The source directory path.')
31
            ->addArgument('target-path', InputArgument::REQUIRED, 'The target directory path.');
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function getConfiguration(InputInterface $input): ConsoleConfigInterface
38
    {
39
        $sourceDirectory = $input->getArgument('source-path');
40
        $targetDirectory = $input->getArgument('target-path');
41
42
        /** @var ConsoleConfigFactoryInterface $factory */
43
        $factory = new DefaultConsoleConfigFactory();
44
        return $factory->invoke($sourceDirectory, $targetDirectory);
0 ignored issues
show
Unused Code introduced by
The call to PhpUnitGen\Configuration...toryInterface::invoke() has too many arguments starting with $targetDirectory. ( Ignorable by Annotation )

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

44
        return $factory->/** @scrutinizer ignore-call */ invoke($sourceDirectory, $targetDirectory);

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...
45
    }
46
}
47