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.1; |
||
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 = []) |
||
60 | |||
61 | /** |
||
62 | * Get the names of directories to scan |
||
63 | * |
||
64 | * @return string[] |
||
65 | */ |
||
66 | public function getDirectoriesToScan(): array |
||
70 | |||
71 | /** |
||
72 | * Get the number of files to display in the results table. |
||
73 | * @return integer |
||
74 | */ |
||
75 | public function getFilesToShow(): int |
||
79 | |||
80 | /** |
||
81 | * Get the minimum score a file need to display. |
||
82 | * @return float |
||
83 | */ |
||
84 | public function getMinScoreToShow(): float |
||
88 | |||
89 | /** |
||
90 | * Get the number of parallel jobs to use to process the files. |
||
91 | * @return integer |
||
92 | */ |
||
93 | public function getParallelJobs(): int |
||
97 | |||
98 | /** |
||
99 | * Get how far back in the git history to go to count commits. |
||
100 | * @return string |
||
101 | */ |
||
102 | public function getCommitsSince(): string |
||
106 | |||
107 | /** |
||
108 | * Get the paths to files to ignore when processing. |
||
109 | * @return array |
||
110 | */ |
||
111 | public function getFilesToIgnore(): array |
||
115 | |||
116 | /** |
||
117 | * Get the file extensions to use when processing. |
||
118 | * @return array |
||
119 | */ |
||
120 | public function getFileExtensions(): array |
||
124 | |||
125 | /** |
||
126 | * @param array $configuration The array containing the configuration values. |
||
127 | * @return void |
||
128 | */ |
||
129 | private function validateDirectoriesToScan(array $configuration): void |
||
135 | |||
136 | /** |
||
137 | * @param array $configuration The array containing the configuration values. |
||
138 | * @return void |
||
139 | */ |
||
140 | private function validateFilesToShow(array $configuration): void |
||
146 | |||
147 | /** |
||
148 | * @param array $configuration The array containing the configuration values. |
||
149 | * @return void |
||
150 | */ |
||
151 | private function validateMinScoreToShow(array $configuration): void |
||
157 | |||
158 | /** |
||
159 | * @param array $configuration The array containing the configuration values. |
||
160 | * @return void |
||
161 | */ |
||
162 | private function validateParallelJobs(array $configuration): void |
||
168 | |||
169 | /** |
||
170 | * @param array $configuration The array containing the configuration values. |
||
171 | * @return void |
||
172 | * @throws InvalidArgumentException If date is in a bad format. |
||
173 | */ |
||
174 | private function validateCommitsSince(array $configuration): void |
||
180 | |||
181 | /** |
||
182 | * @param array $configuration The array containing the configuration values. |
||
183 | * @return void |
||
184 | */ |
||
185 | private function validateFilesToIgnore(array $configuration): void |
||
191 | |||
192 | /** |
||
193 | * @param array $configuration The array containing the configuration values. |
||
194 | * @return void |
||
195 | */ |
||
196 | private function validateFileExtensions(array $configuration): void |
||
202 | } |
||
203 |