Completed
Push — master ( 9003e7...f2c4d3 )
by ReliQ
04:59
created

GitCommandRunner   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A clone() 0 5 1
A getTags() 0 11 2
A pull() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ReliQArts\Docweaver\Services;
6
7
use ReliQArts\Docweaver\Contracts\VCSCommandRunner;
8
use Symfony\Component\Process\Exception\ProcessFailedException;
9
use Symfony\Component\Process\Process;
10
11
final class GitCommandRunner implements VCSCommandRunner
12
{
13
    /**
14
     * @param string $source
15
     * @param string $branch
16
     * @param string $workingDirectory
17
     */
18
    public function clone(string $source, string $branch, string $workingDirectory): void
19
    {
20
        $clone = new Process(sprintf('git clone --branch %s "%s" %s', $branch, $source, $branch), $workingDirectory);
0 ignored issues
show
Documentation introduced by
sprintf('git clone --bra...anch, $source, $branch) is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
21
        $clone->mustRun();
22
    }
23
24
    /**
25
     * @param string $workingDirectory
26
     *
27
     * @throws ProcessFailedException
28
     *
29
     * @return array
30
     */
31
    public function getTags(string $workingDirectory): array
32
    {
33
        $listTags = new Process('git tag -l', $workingDirectory);
0 ignored issues
show
Documentation introduced by
'git tag -l' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
34
        $listTags->mustRun();
35
36
        if ($splitTags = preg_split("/[\n\r]/", $listTags->getOutput())) {
37
            return array_filter(array_map('trim', $splitTags));
38
        }
39
40
        return [];
41
    }
42
43
    /**
44
     * @param string $workingDirectory
45
     *
46
     * @throws ProcessFailedException
47
     */
48
    public function pull(string $workingDirectory): void
49
    {
50
        $pull = new Process('git pull', $workingDirectory);
0 ignored issues
show
Documentation introduced by
'git pull' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
51
        $pull->mustRun();
52
    }
53
}
54