mirror of
https://github.com/retailcrm/Fetch.git
synced 2024-11-22 19:26:01 +03:00
Updated class names to reflect new namespacing, and removed custom exceptions for built in ones.
This commit is contained in:
parent
1e8059d5bd
commit
e78fe27527
@ -81,7 +81,7 @@ class Attachment
|
|||||||
* @param stdClass $structure
|
* @param stdClass $structure
|
||||||
* @param string $partIdentifier
|
* @param string $partIdentifier
|
||||||
*/
|
*/
|
||||||
public function __construct(ImapMessage $message, $structure, $partIdentifier = null)
|
public function __construct(Message $message, $structure, $partIdentifier = null)
|
||||||
{
|
{
|
||||||
$this->messageId = $message->getUid();
|
$this->messageId = $message->getUid();
|
||||||
$this->imapStream = $message->getImapBox()->getImapStream();
|
$this->imapStream = $message->getImapBox()->getImapStream();
|
||||||
@ -90,7 +90,7 @@ class Attachment
|
|||||||
if(isset($partIdentifier))
|
if(isset($partIdentifier))
|
||||||
$this->partId = $partIdentifier;
|
$this->partId = $partIdentifier;
|
||||||
|
|
||||||
$parameters = ImapMessage::getParametersFromStructure($structure);
|
$parameters = Message::getParametersFromStructure($structure);
|
||||||
|
|
||||||
if(isset($parameters['filename']))
|
if(isset($parameters['filename']))
|
||||||
{
|
{
|
||||||
@ -101,7 +101,7 @@ class Attachment
|
|||||||
|
|
||||||
$this->size = $structure->bytes;
|
$this->size = $structure->bytes;
|
||||||
|
|
||||||
$this->mimeType = ImapMessage::typeIdToString($structure->type);
|
$this->mimeType = Message::typeIdToString($structure->type);
|
||||||
|
|
||||||
if(isset($structure->subtype))
|
if(isset($structure->subtype))
|
||||||
$this->mimeType .= '/' . strtolower($structure->subtype);
|
$this->mimeType .= '/' . strtolower($structure->subtype);
|
||||||
@ -123,7 +123,7 @@ class Attachment
|
|||||||
imap_fetchbody($this->imapStream, $this->messageId, $this->partId, FT_UID)
|
imap_fetchbody($this->imapStream, $this->messageId, $this->partId, FT_UID)
|
||||||
: imap_body($this->imapStream, $this->messageId, 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;
|
$this->data = $messageBody;
|
||||||
}
|
}
|
||||||
return $this->data;
|
return $this->data;
|
||||||
|
@ -156,7 +156,7 @@ class ImapMessage
|
|||||||
* @param int $messageUniqueId
|
* @param int $messageUniqueId
|
||||||
* @param Imap $mailbox
|
* @param Imap $mailbox
|
||||||
*/
|
*/
|
||||||
public function __construct($messageUniqueId, Imap $mailbox)
|
public function __construct($messageUniqueId, Server $mailbox)
|
||||||
{
|
{
|
||||||
$this->imapConnection = $mailbox;
|
$this->imapConnection = $mailbox;
|
||||||
$this->uid = $messageUniqueId;
|
$this->uid = $messageUniqueId;
|
||||||
@ -402,7 +402,7 @@ class ImapMessage
|
|||||||
|
|
||||||
if(isset($parameters['name']) || isset($parameters['filename']))
|
if(isset($parameters['name']) || isset($parameters['filename']))
|
||||||
{
|
{
|
||||||
$attachment = new ImapAttachment($this, $structure, $partIdentifier);
|
$attachment = new Attachment($this, $structure, $partIdentifier);
|
||||||
$this->attachments[] = $attachment;
|
$this->attachments[] = $attachment;
|
||||||
}elseif($structure->type == 0 || $structure->type == 1){
|
}elseif($structure->type == 0 || $structure->type == 1){
|
||||||
|
|
||||||
@ -624,7 +624,7 @@ class ImapMessage
|
|||||||
public function setFlag($flag, $enable = true)
|
public function setFlag($flag, $enable = true)
|
||||||
{
|
{
|
||||||
if(!in_array($flag, self::$flagTypes) || $flag == 'recent')
|
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);
|
$flag = '\\' . ucfirst($flag);
|
||||||
|
|
||||||
|
@ -261,12 +261,12 @@ class Imap
|
|||||||
if(isset($this->imapStream))
|
if(isset($this->imapStream))
|
||||||
{
|
{
|
||||||
if(!imap_reopen($this->imapStream, $this->mailbox, $this->options, 1))
|
if(!imap_reopen($this->imapStream, $this->mailbox, $this->options, 1))
|
||||||
throw new ImapException(imap_last_error());
|
throw new \RuntimeException(imap_last_error());
|
||||||
}else{
|
}else{
|
||||||
$imapStream = imap_open($this->getServerString(), $this->username, $this->password, $this->options, 1);
|
$imapStream = imap_open($this->getServerString(), $this->username, $this->password, $this->options, 1);
|
||||||
|
|
||||||
if($imapStream === false)
|
if($imapStream === false)
|
||||||
throw new ImapException(imap_last_error());
|
throw new \RuntimeException(imap_last_error());
|
||||||
|
|
||||||
$this->imapStream = $imapStream;
|
$this->imapStream = $imapStream;
|
||||||
}
|
}
|
||||||
@ -304,7 +304,7 @@ class Imap
|
|||||||
$messages = array();
|
$messages = array();
|
||||||
|
|
||||||
foreach($results as $messageId)
|
foreach($results as $messageId)
|
||||||
$messages[] = new ImapMessage($messageId, $this);
|
$messages[] = new Message($messageId, $this);
|
||||||
|
|
||||||
return $messages;
|
return $messages;
|
||||||
}else{
|
}else{
|
||||||
@ -344,7 +344,7 @@ class Imap
|
|||||||
for($i = 1; $i <= $numMessages; $i++)
|
for($i = 1; $i <= $numMessages; $i++)
|
||||||
{
|
{
|
||||||
$uid = imap_uid($stream, $i);
|
$uid = imap_uid($stream, $i);
|
||||||
$messages[] = new ImapMessage($uid, $this);
|
$messages[] = new Message($uid, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $messages;
|
return $messages;
|
||||||
|
Loading…
Reference in New Issue
Block a user