1 | <?php declare(strict_types = 1); |
||
10 | class Config |
||
11 | { |
||
12 | |||
13 | const FILES_TO_SHOW = 10; |
||
14 | const MINIMUM_SCORE_TO_SHOW = 0; |
||
15 | const AMOUNT_OF_PARALLEL_JOBS = 10; |
||
16 | const SHOW_COMMITS_SINCE = '10 years ago'; |
||
17 | const FILES_TO_IGNORE = []; |
||
18 | const FILE_EXTENSIONS_TO_PARSE = ['php']; |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | private $configuration; |
||
24 | |||
25 | /** |
||
26 | * Create a config with given configuration |
||
27 | * @param array $configuration The array containing the configuration values. |
||
28 | * @return Config |
||
29 | */ |
||
30 | public static function create(array $configuration): Config |
||
34 | |||
35 | /** |
||
36 | * Create a config with default configuration |
||
37 | * @return Config |
||
38 | */ |
||
39 | public static function createFromDefaultValues(): Config |
||
43 | |||
44 | /** |
||
45 | * Config constructor. |
||
46 | * @param array $configuration Raw config data. |
||
47 | * @throws InvalidArgumentException If parameters is badly defined. |
||
48 | */ |
||
49 | private function __construct(array $configuration = []) |
||
57 | |||
58 | /** |
||
59 | * Get the number of files to display in the results table. |
||
60 | * @return integer |
||
61 | */ |
||
62 | public function getFilesToShow(): int |
||
66 | |||
67 | /** |
||
68 | * Get the minimum score a file need to display. |
||
69 | * @return integer |
||
70 | */ |
||
71 | public function getMinScoreToShow(): int |
||
75 | |||
76 | /** |
||
77 | * Get the number of parallel jobs to use to process the files. |
||
78 | * @return integer |
||
79 | */ |
||
80 | public function getParallelJobs(): int |
||
84 | |||
85 | /** |
||
86 | * Get how far back in the git history to go to count commits. |
||
87 | * @return string |
||
88 | */ |
||
89 | public function getCommitsSince(): string |
||
93 | |||
94 | /** |
||
95 | * Get the paths to files to ignore when processing. |
||
96 | * @return array |
||
97 | */ |
||
98 | public function getFilesToIgnore(): array |
||
102 | |||
103 | /** |
||
104 | * Get the file extensions to use when processing. |
||
105 | * @return array |
||
106 | */ |
||
107 | public function getFileExtensions(): array |
||
111 | |||
112 | /** |
||
113 | * @param array $configuration The array containing the configuration values. |
||
114 | * @return void |
||
115 | */ |
||
116 | private function validateConfigurationValues(array $configuration): void |
||
125 | |||
126 | /** |
||
127 | * @param array $configuration The array containing the configuration values. |
||
128 | * @return void |
||
129 | */ |
||
130 | private function validateFilesToShow(array $configuration): void |
||
136 | |||
137 | /** |
||
138 | * @param array $configuration The array containing the configuration values. |
||
139 | * @return void |
||
140 | */ |
||
141 | private function validateMinScoreToShow(array $configuration): void |
||
147 | |||
148 | /** |
||
149 | * @param array $configuration The array containing the configuration values. |
||
150 | * @return void |
||
151 | */ |
||
152 | private function validateParallelJobs(array $configuration): void |
||
158 | |||
159 | /** |
||
160 | * @param array $configuration The array containing the configuration values. |
||
161 | * @return void |
||
162 | * @throws InvalidArgumentException If date is in a bad format. |
||
163 | */ |
||
164 | private function validateCommitsSince(array $configuration): void |
||
175 | |||
176 | /** |
||
177 | * @param array $configuration The array containing the configuration values. |
||
178 | * @return void |
||
179 | */ |
||
180 | private function validateFilesToIgnore(array $configuration): void |
||
186 | |||
187 | /** |
||
188 | * @param array $configuration The array containing the configuration values. |
||
189 | * @return void |
||
190 | */ |
||
191 | private function validateFileExtensions(array $configuration): void |
||
197 | } |
||
198 |