Skip to content

Commit

Permalink
more accurate check with support for zero
Browse files Browse the repository at this point in the history
  • Loading branch information
Lewiscowles1986 committed May 24, 2015
1 parent 397b748 commit c40d2ce
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Fetch/Server.php
Expand Up @@ -323,13 +323,16 @@ protected function setImapStream()
*/
public function numMessages( $mailbox='' )
{
$oldMailbox = $this->getMailBox();
if( $mailbox !== '' ) {
$mboxExists = $this->hasMailbox( $mailbox );
if( $mboxExists ) {
$oldMailbox = $this->getMailBox();
$this->setMailbox( $mailbox );
}
$cnt = imap_num_msg($this->getImapStream());
$this->setMailbox( $oldMailbox );
return $cnt;
$cnt = imap_num_msg( $this->getImapStream() );
if( $mboxExists ) {
$this->setMailbox( $oldMailbox );
}
return ( !$mboxExists && $mailbox !== '' ) ? 0 : $cnt;
}

/**
Expand Down

0 comments on commit c40d2ce

Please sign in to comment.