Completed
Push — master ( 94e1e6...1341d4 )
by Alejandro
16s queued 11s
created

AbstractDatabaseCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
c 1
b 0
f 0
dl 0
loc 18
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A runPhpCommand() 0 4 1
A __construct() 0 5 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Shlinkio\Shlink\CLI\Command\Db;
5
6
use Shlinkio\Shlink\CLI\Command\Util\AbstractLockedCommand;
7
use Symfony\Component\Console\Helper\ProcessHelper;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Lock\Factory as Locker;
10
use Symfony\Component\Process\PhpExecutableFinder;
11
12
use function array_unshift;
13
14
abstract class AbstractDatabaseCommand extends AbstractLockedCommand
15
{
16
    /** @var ProcessHelper */
17
    private $processHelper;
18
    /** @var string */
19
    private $phpBinary;
20
21
    public function __construct(Locker $locker, ProcessHelper $processHelper, PhpExecutableFinder $phpFinder)
22
    {
23
        parent::__construct($locker);
24
        $this->processHelper = $processHelper;
25
        $this->phpBinary = $phpFinder->find(false) ?: 'php';
26
    }
27
28
    protected function runPhpCommand(OutputInterface $output, array $command): void
29
    {
30
        array_unshift($command, $this->phpBinary);
31
        $this->processHelper->run($output, $command);
32
    }
33
}
34