Passed
Pull Request — master (#323)
by Fabien
02:12
created

Config::getParallelJobs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Churn\Configuration;
6
7
/**
8
 * @internal
9
 */
10
class Config
11
{
12
    /**
13
     * @var array<string>
14
     */
15
    private $directoriesToScan = [];
16
17
    /**
18
     * @var integer
19
     */
20
    private $filesToShow = 10;
21
22
    /**
23
     * @var float|null
24
     */
25
    private $minScoreToShow = 0.1;
26
27
    /**
28
     * @var float|null
29
     */
30
    private $maxScoreThreshold = null;
31
32
    /**
33
     * @var integer
34
     */
35
    private $parallelJobs = 10;
36
37
    /**
38
     * @var string
39
     */
40
    private $commitsSince = '10 years ago';
41
42
    /**
43
     * @var array<string>
44
     */
45
    private $filesToIgnore = [];
46
47
    /**
48
     * @var array<string>
49
     */
50
    private $fileExtensions = ['php'];
51
52
    /**
53
     * @var string
54
     */
55
    private $vcs = 'git';
56
57
    /**
58
     * @var string|null
59
     */
60
    private $cachePath = null;
61
62
    /**
63
     * @var array<string>
64
     */
65
    private $hooks = [];
66
67
    /**
68
     * @var string|null
69
     */
70
    private $path;
71
72
    /**
73
     * @var array<int|string>
74
     */
75
    private $unrecognizedKeys = [];
76
77
    /**
78
     * @param string|null $path The path of the configuration file if any.
79
     */
80
    public function __construct(?string $path = null)
81
    {
82
        $this->path = $path;
83
    }
84
85
    /**
86
     * @return array<int|string> The unrecognized keys.
87
     */
88
    public function getUnrecognizedKeys(): array
89
    {
90
        return $this->unrecognizedKeys;
91
    }
92
93
    /**
94
     * @param array<int|string> $unrecognizedKeys The unrecognized keys.
95
     */
96
    public function setUnrecognizedKeys(array $unrecognizedKeys): void
97
    {
98
        $this->unrecognizedKeys = $unrecognizedKeys;
99
    }
100
101
    /**
102
     * Return the path of the folder containing the configuration file.
103
     */
104
    public function getDirPath(): string
105
    {
106
        return null === $this->path
107
            ? \getcwd()
108
            : \dirname($this->path);
109
    }
110
111
    /**
112
     * Get the paths of directories to scan.
113
     *
114
     * @return array<string>
115
     */
116
    public function getDirectoriesToScan(): array
117
    {
118
        return $this->directoriesToScan;
119
    }
120
121
    /**
122
     * @param array<string> $directoriesToScan Paths of directories to scan.
123
     */
124
    public function setDirectoriesToScan(array $directoriesToScan): void
125
    {
126
        $this->directoriesToScan = $directoriesToScan;
127
    }
128
129
    /**
130
     * Get the number of files to display in the results table.
131
     */
132
    public function getFilesToShow(): int
133
    {
134
        return $this->filesToShow;
135
    }
136
137
    /**
138
     * @param integer $filesToShow The number of files to display in the results table.
139
     */
140
    public function setFilesToShow(int $filesToShow): void
141
    {
142
        $this->filesToShow = $filesToShow;
143
    }
144
145
    /**
146
     * Get the minimum score a file need to display (ignored if null).
147
     */
148
    public function getMinScoreToShow(): ?float
149
    {
150
        return $this->minScoreToShow;
151
    }
152
153
    /**
154
     * @param float|null $minScoreToShow The minimum score for a file to be displayed (ignored if null).
155
     */
156
    public function setMinScoreToShow(?float $minScoreToShow): void
157
    {
158
        $this->minScoreToShow = $minScoreToShow;
159
    }
160
161
    /**
162
     * Get the maximum score threshold.
163
     */
164
    public function getMaxScoreThreshold(): ?float
165
    {
166
        return $this->maxScoreThreshold;
167
    }
168
169
    /**
170
     * @param float|null $maxScoreThreshold The maximum score threshold.
171
     */
172
    public function setMaxScoreThreshold(?float $maxScoreThreshold): void
173
    {
174
        $this->maxScoreThreshold = $maxScoreThreshold;
175
    }
176
177
    /**
178
     * Get the number of parallel jobs to use to process the files.
179
     */
180
    public function getParallelJobs(): int
181
    {
182
        return $this->parallelJobs;
183
    }
184
185
    /**
186
     * @param integer $parallelJobs Number of parallel jobs.
187
     */
188
    public function setParallelJobs(int $parallelJobs): void
189
    {
190
        $this->parallelJobs = $parallelJobs;
191
    }
192
193
    /**
194
     * Get how far back in the history to go to count commits.
195
     */
196
    public function getCommitsSince(): string
197
    {
198
        return $this->commitsSince;
199
    }
200
201
    /**
202
     * @param string $commitsSince Criteria to apply when counting changes.
203
     */
204
    public function setCommitsSince(string $commitsSince): void
205
    {
206
        $this->commitsSince = $commitsSince;
207
    }
208
209
    /**
210
     * @return array<string>
211
     */
212
    public function getFilesToIgnore(): array
213
    {
214
        return $this->filesToIgnore;
215
    }
216
217
    /**
218
     * @param array<string> $filesToIgnore The files to ignore.
219
     */
220
    public function setFilesToIgnore(array $filesToIgnore): void
221
    {
222
        $this->filesToIgnore = $filesToIgnore;
223
    }
224
225
    /**
226
     * Get the file extensions to use when processing.
227
     *
228
     * @return array<string>
229
     */
230
    public function getFileExtensions(): array
231
    {
232
        return $this->fileExtensions;
233
    }
234
235
    /**
236
     * @param array<string> $fileExtensions The file extensions to use when processing.
237
     */
238
    public function setFileExtensions(array $fileExtensions): void
239
    {
240
        $this->fileExtensions = $fileExtensions;
241
    }
242
243
    /**
244
     * Get the version control system.
245
     */
246
    public function getVCS(): string
247
    {
248
        return $this->vcs;
249
    }
250
251
    /**
252
     * @param string $vcs The version control system.
253
     */
254
    public function setVCS(string $vcs): void
255
    {
256
        $this->vcs = $vcs;
257
    }
258
259
    /**
260
     * Get the cache file path.
261
     */
262
    public function getCachePath(): ?string
263
    {
264
        return $this->cachePath;
265
    }
266
267
    /**
268
     * @param string|null $cachePath The cache file path.
269
     */
270
    public function setCachePath(?string $cachePath): void
271
    {
272
        $this->cachePath = $cachePath;
273
    }
274
275
    /**
276
     * Get the hooks.
277
     *
278
     * @return array<string>
279
     */
280
    public function getHooks(): array
281
    {
282
        return $this->hooks;
283
    }
284
285
    /**
286
     * @param array<string> $hooks The hooks.
287
     */
288
    public function setHooks(array $hooks): void
289
    {
290
        $this->hooks = $hooks;
291
    }
292
}
293