Completed
Pull Request — master (#440)
by Alejandro
12:02
created

AbstractDatabaseCommand::__construct()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 2
nc 1
nop 3
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