From e78fe275278c42c251a053e52dfee38eef2d3eb3 Mon Sep 17 00:00:00 2001 From: Robert Hafner Date: Sun, 10 Jun 2012 18:38:48 -0700 Subject: [PATCH] Updated class names to reflect new namespacing, and removed custom exceptions for built in ones. --- src/Fetch/Attachment.php | 8 ++++---- src/Fetch/Message.php | 6 +++--- src/Fetch/Server.php | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Fetch/Attachment.php b/src/Fetch/Attachment.php index 4198f1f..358c040 100644 --- a/src/Fetch/Attachment.php +++ b/src/Fetch/Attachment.php @@ -81,7 +81,7 @@ class Attachment * @param stdClass $structure * @param string $partIdentifier */ - public function __construct(ImapMessage $message, $structure, $partIdentifier = null) + public function __construct(Message $message, $structure, $partIdentifier = null) { $this->messageId = $message->getUid(); $this->imapStream = $message->getImapBox()->getImapStream(); @@ -90,7 +90,7 @@ class Attachment if(isset($partIdentifier)) $this->partId = $partIdentifier; - $parameters = ImapMessage::getParametersFromStructure($structure); + $parameters = Message::getParametersFromStructure($structure); if(isset($parameters['filename'])) { @@ -101,7 +101,7 @@ class Attachment $this->size = $structure->bytes; - $this->mimeType = ImapMessage::typeIdToString($structure->type); + $this->mimeType = Message::typeIdToString($structure->type); if(isset($structure->subtype)) $this->mimeType .= '/' . strtolower($structure->subtype); @@ -123,7 +123,7 @@ class Attachment imap_fetchbody($this->imapStream, $this->messageId, $this->partId, FT_UID) : imap_body($this->imapStream, $this->messageId, FT_UID); - $messageBody = ImapMessage::decode($messageBody, $this->encoding); + $messageBody = Message::decode($messageBody, $this->encoding); $this->data = $messageBody; } return $this->data; diff --git a/src/Fetch/Message.php b/src/Fetch/Message.php index b73149f..c8a9d91 100644 --- a/src/Fetch/Message.php +++ b/src/Fetch/Message.php @@ -156,7 +156,7 @@ class ImapMessage * @param int $messageUniqueId * @param Imap $mailbox */ - public function __construct($messageUniqueId, Imap $mailbox) + public function __construct($messageUniqueId, Server $mailbox) { $this->imapConnection = $mailbox; $this->uid = $messageUniqueId; @@ -402,7 +402,7 @@ class ImapMessage if(isset($parameters['name']) || isset($parameters['filename'])) { - $attachment = new ImapAttachment($this, $structure, $partIdentifier); + $attachment = new Attachment($this, $structure, $partIdentifier); $this->attachments[] = $attachment; }elseif($structure->type == 0 || $structure->type == 1){ @@ -624,7 +624,7 @@ class ImapMessage public function setFlag($flag, $enable = true) { if(!in_array($flag, self::$flagTypes) || $flag == 'recent') - throw new ImapException('Unable to set invalid flag "' . $flag . '"'); + throw new \InvalidArgumentException('Unable to set invalid flag "' . $flag . '"'); $flag = '\\' . ucfirst($flag); diff --git a/src/Fetch/Server.php b/src/Fetch/Server.php index a350baf..e5a496b 100644 --- a/src/Fetch/Server.php +++ b/src/Fetch/Server.php @@ -261,12 +261,12 @@ class Imap if(isset($this->imapStream)) { if(!imap_reopen($this->imapStream, $this->mailbox, $this->options, 1)) - throw new ImapException(imap_last_error()); + throw new \RuntimeException(imap_last_error()); }else{ $imapStream = imap_open($this->getServerString(), $this->username, $this->password, $this->options, 1); if($imapStream === false) - throw new ImapException(imap_last_error()); + throw new \RuntimeException(imap_last_error()); $this->imapStream = $imapStream; } @@ -304,7 +304,7 @@ class Imap $messages = array(); foreach($results as $messageId) - $messages[] = new ImapMessage($messageId, $this); + $messages[] = new Message($messageId, $this); return $messages; }else{ @@ -344,7 +344,7 @@ class Imap for($i = 1; $i <= $numMessages; $i++) { $uid = imap_uid($stream, $i); - $messages[] = new ImapMessage($uid, $this); + $messages[] = new Message($uid, $this); } return $messages;