Passed
Push — master ( 1515b4...79261d )
by Kevin
05:02
created

AbstractSchemaResetter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 13
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A runCommand() 0 9 2
1
<?php
2
3
namespace Zenstruck\Foundry\Test;
4
5
use Symfony\Bundle\FrameworkBundle\Console\Application;
6
use Symfony\Component\Console\Input\ArrayInput;
7
use Symfony\Component\Console\Output\BufferedOutput;
8
9
/**
10
 * @internal
11
 */
12
abstract class AbstractSchemaResetter
13
{
14
    abstract public function resetSchema(): void;
15
16
    protected function runCommand(Application $application, string $command, array $parameters = []): void
17
    {
18
        $exit = $application->run(
19
            new ArrayInput(\array_merge(['command' => $command], $parameters)),
20
            $output = new BufferedOutput()
21
        );
22
23
        if (0 !== $exit) {
24
            throw new \RuntimeException(\sprintf('Error running "%s": %s', $command, $output->fetch()));
25
        }
26
    }
27
}
28