Completed
Push — develop ( 67e161...8b0772 )
by Paul
05:50
created

DefaultGenerateCommand::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\ConsoleConfig;
6
use PhpUnitGen\Configuration\ConsoleConfigFactoryInterface;
7
use PhpUnitGen\Configuration\ConsoleConfigInterface;
8
use PhpUnitGen\Configuration\DefaultConsoleConfigFactory;
9
use PhpUnitGen\Configuration\JsonConsoleConfigFactory;
10
use PhpUnitGen\Configuration\PhpConsoleConfigFactory;
11
use PhpUnitGen\Configuration\YamlConsoleConfigFactory;
12
use PhpUnitGen\Exception\InvalidConfigException;
13
use Respect\Validation\Validator;
14
use Symfony\Component\Console\Input\InputArgument;
15
use Symfony\Component\Console\Input\InputInterface;
16
17
/**
18
 * Class DefaultGenerateCommand.
19
 *
20
 * @author     Paul Thébaud <[email protected]>.
21
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
22
 * @license    https://opensource.org/licenses/MIT The MIT license.
23
 * @link       https://github.com/paul-thebaud/phpunit-generator
24
 * @since      Class available since Release 2.0.0.
25
 */
26
class DefaultGenerateCommand extends AbstractGenerateCommand
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected function configure()
32
    {
33
        $this->setName("generate-default")
34
            ->setDescription("Generate unit tests skeletons")
35
            ->setHelp("Use it to generate your unit tests skeletons from a default config")
36
            ->addArgument('source-path', InputArgument::REQUIRED, 'The source directory path.')
37
            ->addArgument('target-path', InputArgument::REQUIRED, 'The target directory path.');
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function getConfiguration(InputInterface $input): ConsoleConfigInterface
44
    {
45
        $sourceDirectory = $input->getArgument('source-path');
46
        $targetDirectory = $input->getArgument('target-path');
47
48
        /** @var ConsoleConfigFactoryInterface $factory */
49
        $factory = new DefaultConsoleConfigFactory();
50
        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

50
        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...
51
    }
52
}
53