|
@@ -200,16 +200,15 @@ class Validate
|
200
|
200
|
$Heaviest = array_slice($Sorted, 0, 20);
|
201
|
201
|
$Matches = [];
|
202
|
202
|
|
|
203
|
+ # Distill the file format
|
|
204
|
+ $FileTypes = $FileTypes[$Category];
|
|
205
|
+ $FileTypeNames = array_keys($FileTypes);
|
|
206
|
+
|
203
|
207
|
foreach ($Heaviest as $Heaviest) {
|
204
|
208
|
# Collect the last 2 period-separated tokens
|
205
|
209
|
$Extensions = array_slice(explode('.', strtolower($Heaviest[1])), -2, 2);
|
206
|
210
|
$Matches = array_merge($Extensions);
|
207
|
211
|
|
208
|
|
- # Distill the file format
|
209
|
|
- $FileTypes = $FileTypes[$Category];
|
210
|
|
- $FileTypeNames = array_keys($FileTypes);
|
211
|
|
-
|
212
|
|
- # todo: Find the smallest possible number of iterations
|
213
|
212
|
# todo: Reduce nesting by one level
|
214
|
213
|
foreach ($Matches as $Match) {
|
215
|
214
|
$Match = strtolower($Match);
|
|
@@ -220,11 +219,11 @@ class Validate
|
220
|
219
|
if (in_array($Match, $SearchMe[1])) {
|
221
|
220
|
return $SearchMe[0];
|
222
|
221
|
break;
|
223
|
|
- } else {
|
224
|
|
- return 'Other';
|
225
|
|
- break;
|
226
|
222
|
}
|
227
|
223
|
}
|
|
224
|
+
|
|
225
|
+ # Return the last element (Other or None)
|
|
226
|
+ return array_key_last($FileTypes);
|
228
|
227
|
}
|
229
|
228
|
}
|
230
|
229
|
}
|