ProcessFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 6 2
1
<?php
2
3
/**
4
 * Copyright MediaCT. All rights reserved.
5
 * https://www.mediact.nl
6
 */
7
8
namespace Mediact\TestingSuite\Composer\Factory;
9
10
use Symfony\Component\Process\Process;
11
12
class ProcessFactory implements ProcessFactoryInterface
13
{
14
    /**
15
     * Create a new Process instance.
16
     *
17
     * @param string $commandLine
18
     *
19
     * @return Process
20
     */
21 1
    public function create(string $commandLine): Process
22
    {
23
        // See https://github.com/composer/composer/blob/1.10.17/src/Composer/Util/ProcessExecutor.php#L68:L72
24 1
        return method_exists(Process::class, 'fromShellCommandline')
25 1
            ? Process::fromShellCommandline($commandLine) // Symfony >= 4.2
26 1
            : new Process($commandLine); // Symfony < 4.2
0 ignored issues
show
Bug introduced by
$commandLine of type string is incompatible with the type array expected by parameter $command of Symfony\Component\Process\Process::__construct(). ( Ignorable by Annotation )

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

26
            : new Process(/** @scrutinizer ignore-type */ $commandLine); // Symfony < 4.2
Loading history...
27
    }
28
}
29