Skip to content

Commit

Permalink
Consts For Sort Ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
tzaoh committed Apr 30, 2016
1 parent dbd60fc commit 8f7f1bd
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/Filesystem/Folder.php
Expand Up @@ -52,6 +52,16 @@ class Folder
*/
const SKIP = 'skip';

/**
* Sort mode by name
*/
const SORT_NAME = 'name';

/**
* Sort mode by time
*/
const SORT_TIME = 'time';

/**
* Path to Folder.
*
Expand Down Expand Up @@ -165,7 +175,7 @@ public function cd($path)
* @param bool $fullPath True returns the full path
* @return array Contents of current directory as an array, an empty array on failure
*/
public function read($sort = 'name', $exceptions = false, $fullPath = false)
public function read($sort = self::SORT_NAME, $exceptions = false, $fullPath = false)
{
$dirs = $files = [];

Expand Down Expand Up @@ -203,10 +213,10 @@ public function read($sort = 'name', $exceptions = false, $fullPath = false)
}

if ($sort || $this->sort) {
if ($sort === 'time') {
if ($sort === self::SORT_TIME or $this->sort === self::SORT_TIME) {
ksort($dirs);
ksort($files);
} else {
} else if ($sort === self::SORT_NAME or $this->sort === self::SORT_NAME) {
sort($dirs);
sort($files);
}
Expand Down

0 comments on commit 8f7f1bd

Please sign in to comment.