From 657cec4b4eeed70e8eb84979786165b8fa40853a Mon Sep 17 00:00:00 2001 From: Susann Sgorzaly Date: Thu, 22 Feb 2018 20:41:03 +0100 Subject: [PATCH] added enum for sort --- src/Csv.php | 12 +++--------- src/enums/SortEnum.php | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 src/enums/SortEnum.php diff --git a/src/Csv.php b/src/Csv.php index 74381e4..f75bb0d 100644 --- a/src/Csv.php +++ b/src/Csv.php @@ -1,6 +1,7 @@ titles = $head; if (!empty($this->sort_by)) { - $sort_type = SORT_REGULAR; - if ($this->sort_type == 'numeric') { - $sort_type = SORT_NUMERIC; - } elseif ($this->sort_type == 'string') { - $sort_type = SORT_STRING; - } - - $this->sort_reverse ? krsort($rows, $sort_type) : ksort($rows, $sort_type); + $this->sort_reverse ? krsort($rows, $this->sort_type) : ksort($rows, $this->sort_type); if ($this->offset !== null || $this->limit !== null) { $rows = array_slice($rows, ($this->offset === null ? 0 : $this->offset), $this->limit, true); diff --git a/src/enums/SortEnum.php b/src/enums/SortEnum.php new file mode 100644 index 0000000..01a37b0 --- /dev/null +++ b/src/enums/SortEnum.php @@ -0,0 +1,18 @@ +