/** * @test */ public function foo() { $array = [new Folder('foo', 'bar', 'baz', 'qux', 'quux'), new Folder('bar', 'bar', 'baz', 'qux', 'quux'), new Folder('baz', 'bar', 'baz', 'qux', 'quux'), new Folder('qux', 'bar', 'baz', 'qux', 'quux'), new Folder('quux', 'bar', 'baz', 'qux', 'quux')]; if (Sorter::sort($array, 'name')) { array_map(function ($arr) { echo $arr->getName() . "\n"; }, $array); } }
Sorter::sort($folders, 'name'); // Uses getMailbox() method from the ImapConnection helper trait, or you can do: $imap->getConnection()->getMailbox()->getFolder(); $currentFolder = $mailboxService->getMailbox()->getFolder(); $aliases = $mailboxService->getAliases(); $isTrash = false; if (isset($aliases['trash'])) { if ($aliases['trash'] == $currentFolder) { $isTrash = true; } } $cacheManager = new ImapMessageCache($messageCache, $imap); $messages = $cacheManager->getAllCachedMessages(); $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1; $recordsPerPage = 25; $messages = $messages->toArray(); if (Sorter::sortMessagesByDate($messages)) { $messages = array_slice($messages, $recordsPerPage * ($page - 1), $recordsPerPage); } else { die('Oops! Looks like something went wrong.'); } ?> <html> <head> <title>Emails</title> <script src="https://code.jquery.com/jquery-1.12.0.min.js"></script> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> <!-- Optional theme -->