1 | <?php declare(strict_types = 1); |
||
7 | class Config |
||
8 | { |
||
9 | const DIRECTORIES_TO_SCAN = []; |
||
10 | const FILES_TO_SHOW = 10; |
||
11 | const MINIMUM_SCORE_TO_SHOW = 0; |
||
12 | const AMOUNT_OF_PARALLEL_JOBS = 10; |
||
13 | const SHOW_COMMITS_SINCE = '10 years ago'; |
||
14 | const FILES_TO_IGNORE = []; |
||
15 | const FILE_EXTENSIONS_TO_PARSE = ['php']; |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | private $configuration; |
||
21 | |||
22 | /** |
||
23 | * Create a config with given configuration |
||
24 | * @param array $configuration The array containing the configuration values. |
||
25 | * @return Config |
||
26 | */ |
||
27 | public static function create(array $configuration): Config |
||
31 | |||
32 | /** |
||
33 | * Create a config with default configuration |
||
34 | * @return Config |
||
35 | */ |
||
36 | public static function createFromDefaultValues(): Config |
||
40 | |||
41 | /** |
||
42 | * Config constructor. |
||
43 | * @param array $configuration Raw config data. |
||
44 | * @throws InvalidArgumentException If parameters is badly defined. |
||
45 | */ |
||
46 | private function __construct(array $configuration = []) |
||
54 | |||
55 | /** |
||
56 | * Get the names of directories to scan |
||
57 | * |
||
58 | * @return string[] |
||
59 | */ |
||
60 | public function getDirectoriesToScan(): array |
||
64 | |||
65 | /** |
||
66 | * Get the number of files to display in the results table. |
||
67 | * @return integer |
||
68 | */ |
||
69 | public function getFilesToShow(): int |
||
73 | |||
74 | /** |
||
75 | * Get the minimum score a file need to display. |
||
76 | * @return integer |
||
77 | */ |
||
78 | public function getMinScoreToShow(): int |
||
82 | |||
83 | /** |
||
84 | * Get the number of parallel jobs to use to process the files. |
||
85 | * @return integer |
||
86 | */ |
||
87 | public function getParallelJobs(): int |
||
91 | |||
92 | /** |
||
93 | * Get how far back in the git history to go to count commits. |
||
94 | * @return string |
||
95 | */ |
||
96 | public function getCommitsSince(): string |
||
100 | |||
101 | /** |
||
102 | * Get the paths to files to ignore when processing. |
||
103 | * @return array |
||
104 | */ |
||
105 | public function getFilesToIgnore(): array |
||
109 | |||
110 | /** |
||
111 | * Get the file extensions to use when processing. |
||
112 | * @return array |
||
113 | */ |
||
114 | public function getFileExtensions(): array |
||
118 | |||
119 | /** |
||
120 | * @param array $configuration The array containing the configuration values. |
||
121 | * @return void |
||
122 | */ |
||
123 | private function validateConfigurationValues(array $configuration) |
||
133 | |||
134 | /** |
||
135 | * @param array $configuration The array containing the configuration values. |
||
136 | * @return void |
||
137 | */ |
||
138 | private function validateDirectoriesToScan(array $configuration) |
||
144 | |||
145 | /** |
||
146 | * @param array $configuration The array containing the configuration values. |
||
147 | * @return void |
||
148 | */ |
||
149 | private function validateFilesToShow(array $configuration) |
||
155 | |||
156 | /** |
||
157 | * @param array $configuration The array containing the configuration values. |
||
158 | * @return void |
||
159 | */ |
||
160 | private function validateMinScoreToShow(array $configuration) |
||
166 | |||
167 | /** |
||
168 | * @param array $configuration The array containing the configuration values. |
||
169 | * @return void |
||
170 | */ |
||
171 | private function validateParallelJobs(array $configuration) |
||
177 | |||
178 | /** |
||
179 | * @param array $configuration The array containing the configuration values. |
||
180 | * @return void |
||
181 | * @throws InvalidArgumentException If date is in a bad format. |
||
182 | */ |
||
183 | private function validateCommitsSince(array $configuration) |
||
189 | |||
190 | /** |
||
191 | * @param array $configuration The array containing the configuration values. |
||
192 | * @return void |
||
193 | */ |
||
194 | private function validateFilesToIgnore(array $configuration) |
||
200 | |||
201 | /** |
||
202 | * @param array $configuration The array containing the configuration values. |
||
203 | * @return void |
||
204 | */ |
||
205 | private function validateFileExtensions(array $configuration) |
||
211 | } |
||
212 |