Completed
Pull Request — master (#84)
by
unknown
02:18
created

Config::getFormula()   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\Values;
5
6
class Config
7
{
8
    /**
9
     * The number of files to display in the results table.
10
     * @var integer
11
     */
12
    private $filesToShow;
13
14
    /**
15
     * The number of parallel jobs to use to process the files.
16
     * @var integer
17
     */
18
    private $parallelJobs;
19
20
    /**
21
     * How far back in the git history to go to count commits.
22
     * @var string
23
     */
24
    private $commitsSince;
25
26
    /**
27
     * The paths to files to ignore when processing.
28
     * @var array
29
     */
30
    private $filesToIgnore;
31
32
    /**
33
     * The math formula to calculate the score
34
     * @var string
35
     */
36
    private $formula;
37
38
    /**
39
     * Config constructor.
40
     * @param array $rawData Raw config data.
41
     */
42
    public function __construct(array $rawData = [])
43
    {
44
        $this->filesToShow = $rawData['filesToShow'] ?? 10;
45
        $this->parallelJobs = $rawData['parallelJobs'] ?? 10;
46
        $this->commitsSince = $rawData['commitsSince'] ?? '10 years ago';
47
        $this->filesToIgnore = $rawData['filesToIgnore'] ?? [];
48
        $this->formula = $rawData['formula'] ?? '[[commits]] + [[complexity]]';
49
    }
50
51
    /**
52
     * Get the number of files to display in the results table.
53
     * @return integer
54
     */
55
    public function getFilesToShow(): int
56
    {
57
        return $this->filesToShow;
58
    }
59
60
    /**
61
     * Get the number of parallel jobs to use to process the files.
62
     * @return integer
63
     */
64
    public function getParallelJobs(): int
65
    {
66
        return $this->parallelJobs;
67
    }
68
69
    /**
70
     * Get how far back in the git history to go to count commits.
71
     * @return string
72
     */
73
    public function getCommitsSince(): string
74
    {
75
        return $this->commitsSince;
76
    }
77
78
    /**
79
     * Get the paths to files to ignore when processing.
80
     * @return array
81
     */
82
    public function getFilesToIgnore(): array
83
    {
84
        return $this->filesToIgnore;
85
    }
86
87
    /**
88
     * Get the formula to calculate the score
89
     * @return string
90
     */
91
    public function getFormula(): string
92
    {
93
        return $this->formula;
94
    }
95
}
96