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

ProcessFactory::createGitCommitProcess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php declare(strict_types = 1);
2
3
namespace Churn\Factories;
4
5
use Churn\Processes\ChurnProcess;
6
use Churn\Values\File;
7
use Symfony\Component\Process\Process;
8
9
class ProcessFactory
10
{
11
    /**
12
     * Creates a Git Commit Process that will run on $file.
13
     * @param File $file File that the process will execute on.
14
     * @return ChurnProcess
15
     */
16
    public function createGitCommitProcess(File $file): ChurnProcess
17
    {
18
        $process = new Process(
19
            'git -C ' . getcwd() . " log --name-only --pretty=format: " . $file->getFullPath(). " | sort | uniq -c | sort -nr"
20
        );
21
22
        return new ChurnProcess($file, $process, 'GitCommitProcess');
23
    }
24
25
    /**
26
     * Creates a Cyclomatic Complexity Process that will run on $file.
27
     * @param File $file File that the process will execute on.
28
     * @return ChurnProcess
29
     */
30
    public function createCyclomaticComplexityProcess(File $file): ChurnProcess
31
    {
32
        $rootFolder = __DIR__ . '/../../';
33
34
        $process = new Process(
35
            "php {$rootFolder}CyclomaticComplexityAssessorRunner {$file->getFullPath()}"
36
        );
37
38
        return new ChurnProcess($file, $process, 'CyclomaticComplexityProcess');
39
    }
40
}
41