Completed
Push — master ( 2533ab...858698 )
by Bill
02:46 queued 01:04
created

ChurnProcess::isSuccessful()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php declare(strict_types = 1);
2
3
4
namespace Churn\Processes;
5
6
use Churn\Values\File;
7
use Symfony\Component\Process\Process;
8
9
class ChurnProcess
10
{
11
    /**
12
     * The Symfony Process Component.
13
     * @var Process
14
     */
15
    private $process;
16
17
    /**
18
     * GitCommitCountProcess constructor.
19
     * @param File    $file    The file the process is being executed on.
20
     * @param Process $process The process being executed on the file.
21
     * @param string  $type    The type of process.
22
     */
23
    public function __construct(File $file, Process $process, string $type)
24
    {
25
        $this->file = $file;
0 ignored issues
show
Bug introduced by
The property file does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
26
        $this->process = $process;
27
        $this->type = $type;
0 ignored issues
show
Bug introduced by
The property type does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
28
    }
29
30
    /**
31
     * Start the process.
32
     * @return void
33
     */
34
    public function start()
35
    {
36
        $this->process->start();
37
    }
38
39
    /**
40
     * Determines if the process was successful.
41
     * @return boolean
42
     */
43
    public function isSuccessful(): bool
44
    {
45
        return $this->process->isSuccessful();
46
    }
47
48
    /**
49
     * Gets the output of the process.
50
     * @return string
51
     */
52
    public function getOutput(): string
53
    {
54
        return $this->process->getOutput();
55
    }
56
57
    /**
58
     * Gets the file name of the file the process
59
     * is being executed on.
60
     * @return string
61
     */
62
    public function getFilename(): string
63
    {
64
        return $this->file->getDisplayPath();
65
    }
66
67
    /**
68
     * Gets a unique key used for storing the process in data structures.
69
     * @return string
70
     */
71
    public function getKey(): string
72
    {
73
        return $this->getType() . $this->file->getFullPath();
74
    }
75
76
    /**
77
     * Get the type of this process.
78
     * @return string
79
     */
80
    public function getType(): string
81
    {
82
        return $this->type;
83
    }
84
}
85