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

ProcessFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 32
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createGitCommitProcess() 0 8 1
A createCyclomaticComplexityProcess() 0 10 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