Skip to content

Commit

Permalink
Added hasMailbox to Connection
Browse files Browse the repository at this point in the history
  • Loading branch information
boekkooi committed Apr 16, 2015
1 parent e816ad2 commit 393aa78
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ public function getMailboxes()
return $this->mailboxes;
}

/**
* Check that a mailbox with the given name exists
*
* @param string $name Mailbox name
*
* @return bool
*/
public function hasMailbox($name)
{
return in_array($name, $this->getMailboxNames());
}

/**
* Get a mailbox by its name
*
Expand All @@ -59,7 +71,7 @@ public function getMailboxes()
*/
public function getMailbox($name)
{
if (!in_array($name, $this->getMailboxNames())) {
if (!$this->hasMailbox($name)) {
throw new MailboxDoesNotExistException($name);
}

Expand Down

0 comments on commit 393aa78

Please sign in to comment.