public sort ( array $opts = [] ) : array | ||
$opts | array | Options: - delimiter: (string) The delimiter to use. DEFAULT: '.' - inbox: (boolean) Always put INBOX at the head of the list? DEFAULT: Yes - noupdate: (boolean) Do not update the object's mailbox list? DEFAULT: true |
return | array | List of sorted mailboxes (index association is kept). |
public function sort(array $opts = array())
{
$this->_delimiter = isset($opts['delimiter']) ? $opts['delimiter'] : '.';
$this->_sortinbox = !isset($opts['inbox']) || !empty($opts['inbox']);
if (empty($opts['noupdate'])) {
$mboxes =& $this->_mboxes;
} else {
$mboxes = $this->_mboxes;
}
uasort($mboxes, array($this, '_mboxCompare'));
return $mboxes;
}
/** * @dataProvider noUpdateOfListObjectProvider */ public function testNoUpdateOfListObject($mboxes, $expected) { $list_ob = new Horde_Imap_Client_Mailbox_List($mboxes); $sorted = $list_ob->sort(array('noupdate' => true)); $this->assertEquals($expected, array_values($sorted)); $this->assertEquals($mboxes, array_values(iterator_to_array($list_ob))); $list_ob = new Horde_Imap_Client_Mailbox_List($mboxes); $sorted = $list_ob->sort(); $this->assertEquals($expected, array_values($sorted)); $this->assertEquals($expected, array_values(iterator_to_array($list_ob))); }