Browse Source

Fix the fallback functionality

pjc 5 years ago
parent
commit
0133b6aeeb
1 changed files with 7 additions and 8 deletions
  1. 7
    8
      classes/validate.class.php

+ 7
- 8
classes/validate.class.php View File

@@ -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
     }

Loading…
Cancel
Save