Completed
Push — master ( a959b5...b73961 )
by Alejandro
28s queued 12s
created

AbstractDatabaseCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 23
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A runPhpCommand() 0 4 1
A getLockConfig() 0 3 1
A __construct() 0 5 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Shlinkio\Shlink\CLI\Command\Db;
6
7
use Shlinkio\Shlink\CLI\Command\Util\AbstractLockedCommand;
8
use Shlinkio\Shlink\CLI\Command\Util\LockedCommandConfig;
9
use Symfony\Component\Console\Helper\ProcessHelper;
10
use Symfony\Component\Console\Output\OutputInterface;
11
use Symfony\Component\Lock\Factory as Locker;
12
use Symfony\Component\Process\PhpExecutableFinder;
13
14
use function array_unshift;
15
16
abstract class AbstractDatabaseCommand extends AbstractLockedCommand
17
{
18
    /** @var ProcessHelper */
19
    private $processHelper;
20
    /** @var string */
21
    private $phpBinary;
22
23 5
    public function __construct(Locker $locker, ProcessHelper $processHelper, PhpExecutableFinder $phpFinder)
24
    {
25 5
        parent::__construct($locker);
26 5
        $this->processHelper = $processHelper;
27 5
        $this->phpBinary = $phpFinder->find(false) ?: 'php';
28
    }
29
30 2
    protected function runPhpCommand(OutputInterface $output, array $command): void
31
    {
32 2
        array_unshift($command, $this->phpBinary);
33 2
        $this->processHelper->mustRun($output, $command);
34
    }
35
36 5
    protected function getLockConfig(): LockedCommandConfig
37
    {
38 5
        return new LockedCommandConfig($this->getName(), true);
0 ignored issues
show
Bug introduced by
It seems like $this->getName() can also be of type null; however, parameter $lockName of Shlinkio\Shlink\CLI\Comm...ndConfig::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
        return new LockedCommandConfig(/** @scrutinizer ignore-type */ $this->getName(), true);
Loading history...
39
    }
40
}
41