SetupCommand::setUpMatchFixtures()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
3
namespace OSS\CoreBundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\ArrayInput;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\NullOutput;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
class SetupCommand extends ContainerAwareCommand
12
{
13
    /**
14
     * @var InputInterface
15
     */
16
    private $input;
17
18
    /**
19
     * @var OutputInterface
20
     */
21
    private $output;
22
23
    protected function configure()
24
    {
25
        $this->setName('oss:setup');
26
        $this->setDescription('Sets up the game.');
27
    }
28
29
    protected function execute(InputInterface $input, OutputInterface $output)
30
    {
31
        $this->input = $input;
32
        $this->output = $output;
33
34
        $this->executeCommand('doctrine:schema:drop', 'dropping database schema', '--force');
35
        $this->executeCommand('doctrine:schema:create', 'creating database schema');
36
        $this->executeCommand('doctrine:fixtures:load', 'loading all fixtures');
37
        $this->setUpMatchFixtures($output);
0 ignored issues
show
Unused Code introduced by
The call to SetupCommand::setUpMatchFixtures() has too many arguments starting with $output.

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.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
38
    }
39
40
    /**
41
     * @param string $commandName
42
     * @param string $message
43
     * @param string $params
44
     *
45
     * @throws \Exception
46
     */
47
    private function executeCommand($commandName, $message, $params = '')
48
    {
49
        $this->commandStart($message);
50
        $command = $this->getApplication()->find($commandName);
51
        $input = array('command' => $commandName);
52
        if (!empty($params)) {
53
            $input[$params] = true;
54
        }
55
        $arrayInput = new ArrayInput($input);
56
        $arrayInput->setInteractive(false);
57
        $command->run($arrayInput, new NullOutput());
58
        $this->output->writeln('<info>OK</info>');
59
    }
60
61
    private function setUpMatchFixtures()
62
    {
63
        $this->commandStart('setting up match fixtures');
64
        $this->getContainer()->get('oss.core.service.fixture')->createFixtures(1);
65
        $this->output->writeln('<info>OK</info>');
66
    }
67
68
    /**
69
     * @param string $message
70
     */
71
    private function commandStart($message)
72
    {
73
        $this->output->write($message . substr('..................................................', 0, 50 - strlen($message)));
74
    }
75
}
76