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

AbstractDatabaseCommand::getLockConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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