Skip to content

Commit 69c3a72

Browse files
committed
Replace magic strings with enums in sorting logic
Create new SortingMethod enum alongside deprecated FolderSortingMethod for backward compatibility. Replace all magic string direction values ('asc'/'desc') with SortingOrder enum constants. Add validateDirection() method to gracefully handle invalid direction values by defaulting to descending order. Include comprehensive test coverage for invalid sorting inputs.
1 parent 30a281e commit 69c3a72

14 files changed

+823
-75
lines changed

config/log-viewer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
use Opcodes\LogViewer\Enums\FolderSortingMethod;
3+
use Opcodes\LogViewer\Enums\SortingMethod;
44
use Opcodes\LogViewer\Enums\SortingOrder;
55
use Opcodes\LogViewer\Enums\Theme;
66

@@ -283,13 +283,13 @@
283283
'use_local_storage' => true,
284284

285285
// Method to sort the folders. Other options: `Alphabetical`, `ModifiedTime`
286-
'folder_sorting_method' => FolderSortingMethod::ModifiedTime,
286+
'folder_sorting_method' => SortingMethod::ModifiedTime,
287287

288288
// Order to sort the folders. Other options: `Ascending`, `Descending`
289289
'folder_sorting_order' => SortingOrder::Descending,
290290

291291
// Method for sorting log-files into directories. Other options: `Alphabetical`, `ModifiedTime`
292-
'file_sorting_method' => FolderSortingMethod::ModifiedTime,
292+
'file_sorting_method' => SortingMethod::ModifiedTime,
293293

294294
// Order to sort the logs. Other options: `Ascending`, `Descending`
295295
'log_sorting_order' => SortingOrder::Descending,

0 commit comments

Comments
 (0)