From a502dfe1629d3c5ae3d95bf952c71b68c4d3e4c1 Mon Sep 17 00:00:00 2001 From: Webklex Date: Tue, 14 Aug 2018 20:38:57 +0200 Subject: [PATCH] Folder delimiter check added #137 --- CHANGELOG.md | 4 ++-- src/Client.php | 6 +++--- src/Folder.php | 33 ++++++++++++++++++++++++--------- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a42fdee1..d1ce95d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,13 +6,13 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip ## [UNRELEASED] ### Fixed -- NaN +- Folder delimiter check added #137 ### Added - NaN ### Affected Classes -- NaN +- [Folder::class](src/IMAP/Folder.php) ## 0.0.1 - 2018-08-13 ### Added diff --git a/src/Client.php b/src/Client.php index 4a2f7b9b..ee69c6a3 100644 --- a/src/Client.php +++ b/src/Client.php @@ -383,8 +383,8 @@ public function deleteFolder($name, $expunge = true) { * * @return MessageCollection * @throws ConnectionFailedException + * @throws Exceptions\InvalidWhereQueryCriteriaException * @throws GetMessagesFailedException - * @throws MessageSearchValidationException * * @deprecated 1.0.5.2:2.0.0 No longer needed. Use Folder::getMessages() instead * @see Folder::getMessages() @@ -404,8 +404,8 @@ public function getMessages(Folder $folder, $criteria = 'ALL', $fetch_options = * * @return MessageCollection * @throws ConnectionFailedException + * @throws Exceptions\InvalidWhereQueryCriteriaException * @throws GetMessagesFailedException - * @throws MessageSearchValidationException * * @deprecated 1.0.5:2.0.0 No longer needed. Use Folder::getMessages('UNSEEN') instead * @see Folder::getMessages() @@ -426,8 +426,8 @@ public function getUnseenMessages(Folder $folder, $criteria = 'UNSEEN', $fetch_o * * @return MessageCollection * @throws ConnectionFailedException + * @throws Exceptions\InvalidWhereQueryCriteriaException * @throws GetMessagesFailedException - * @throws MessageSearchValidationException * * @deprecated 1.0.5:2.0.0 No longer needed. Use Folder::searchMessages() instead * @see Folder::searchMessages() diff --git a/src/Folder.php b/src/Folder.php index 0a9f9a41..a20af95f 100644 --- a/src/Folder.php +++ b/src/Folder.php @@ -111,17 +111,17 @@ class Folder { * * @param \Webklex\PHPIMAP\Client $client * - * @param object $folder + * @param object structure */ - public function __construct(Client $client, $folder) { + public function __construct(Client $client, $structure) { $this->client = $client; - $this->delimiter = $folder->delimiter; - $this->path = $folder->name; - $this->fullName = $this->decodeName($folder->name); + $this->setDelimiter($structure->delimiter); + $this->path = $structure->name; + $this->fullName = $this->decodeName($structure->name); $this->name = $this->getSimpleName($this->delimiter, $this->fullName); - $this->parseAttributes($folder->attributes); + $this->parseAttributes($structure->attributes); } /** @@ -187,6 +187,7 @@ public function setChildren($children = []) { * @param boolean $fetch_flags * * @return Message|null + * @throws Exceptions\ConnectionFailedException */ public function getMessage($uid, $msglist = null, $fetch_options = null, $fetch_body = false, $fetch_attachment = false, $fetch_flags = true) { if (imap_msgno($this->getClient()->getConnection(), $uid) > 0) { @@ -210,8 +211,8 @@ public function getMessage($uid, $msglist = null, $fetch_options = null, $fetch_ * * @return MessageCollection * @throws Exceptions\ConnectionFailedException + * @throws Exceptions\InvalidWhereQueryCriteriaException * @throws GetMessagesFailedException - * @throws MessageSearchValidationException */ public function getMessages($criteria = 'ALL', $fetch_options = null, $fetch_body = true, $fetch_attachment = true, $fetch_flags = true, $limit = null, $page = 1, $charset = "UTF-8") { @@ -234,8 +235,8 @@ public function getMessages($criteria = 'ALL', $fetch_options = null, $fetch_bod * * @return MessageCollection * @throws Exceptions\ConnectionFailedException + * @throws Exceptions\InvalidWhereQueryCriteriaException * @throws GetMessagesFailedException - * @throws MessageSearchValidationException * * @deprecated 1.0.5:2.0.0 No longer needed. Use Folder::getMessages('UNSEEN') instead * @see Folder::getMessages() @@ -270,8 +271,8 @@ public function getUnseenMessages($criteria = 'UNSEEN', $fetch_options = null, $ * @return MessageCollection * * @throws Exceptions\ConnectionFailedException + * @throws Exceptions\InvalidWhereQueryCriteriaException * @throws GetMessagesFailedException - * @throws MessageSearchValidationException * * @doc http://php.net/manual/en/function.imap-search.php * imap_search() only supports IMAP2 search criterias, because the function mail_criteria() (from c-client lib) @@ -404,6 +405,7 @@ public function move($target_mailbox, $expunge = true) { * SA_ALL - set all of the above * * @return object + * @throws Exceptions\ConnectionFailedException */ public function getStatus($options) { return imap_status($this->client->getConnection(), $this->path, $options); @@ -417,6 +419,7 @@ public function getStatus($options) { * @param string $internal_date * * @return bool + * @throws Exceptions\ConnectionFailedException */ public function appendMessage($message, $options = null, $internal_date = null) { return imap_append($this->client->getConnection(), $this->path, $message, $options, $internal_date); @@ -430,4 +433,16 @@ public function appendMessage($message, $options = null, $internal_date = null) public function getClient() { return $this->client; } + + + /** + * @param $delimiter + */ + public function setDelimiter($delimiter){ + if(in_array($delimiter, [null, '', ' ', false]) === true) { + $delimiter = ClientManager::$config['options']['delimiter']; + } + + $this->delimiter = $delimiter; + } }