From 52fa8113d87c56a8260aa6f27b87340ccc5834ed Mon Sep 17 00:00:00 2001 From: Ameir Abdeldayem Date: Fri, 13 Nov 2015 18:57:08 -0500 Subject: [PATCH 1/2] Support returning IMAP delimiter. --- src/Storage/Imap.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Storage/Imap.php b/src/Storage/Imap.php index 240c3692..c6ed8b55 100644 --- a/src/Storage/Imap.php +++ b/src/Storage/Imap.php @@ -29,6 +29,12 @@ class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\W */ protected $currentFolder = ''; + /** + * IMAP folder delimiter character + * @var string + */ + protected $delimiter; + /** * IMAP flags to constants translation * @var array @@ -331,6 +337,7 @@ public function getFolders($rootFolder = null) $parentFolder->$localName = $folder; array_push($folderStack, $parentFolder); $parentFolder = $folder; + $this->delimiter = $data['delim']; break; } elseif ($stack) { $parent = array_pop($stack); @@ -504,4 +511,17 @@ public function setFlags($id, $flags) throw new Exception\RuntimeException('cannot set flags, have you tried to set the recent flag or special chars?'); } } + + /** + * get IMAP delimiter + * + * @return string|null + */ + public function delimiter() + { + if (!isset($this->delimiter)) { + $this->getFolders(); + } + return $this->delimiter; + } } From 1863c83b592cbc7937d2cdc7e71f2e74888b504e Mon Sep 17 00:00:00 2001 From: Ameir Abdeldayem Date: Sun, 10 Apr 2016 14:13:10 -0400 Subject: [PATCH 2/2] Add test for IMAP delimiter. --- test/Storage/ImapTest.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/Storage/ImapTest.php b/test/Storage/ImapTest.php index d30becf9..9111b82f 100644 --- a/test/Storage/ImapTest.php +++ b/test/Storage/ImapTest.php @@ -697,4 +697,11 @@ public function testCountFlags() $this->assertEquals($mail->countMessages([Storage::FLAG_SEEN, Storage::FLAG_FLAGGED]), 0); $this->assertEquals($mail->countMessages(Storage::FLAG_FLAGGED), 0); } + + public function testDelimiter() + { + $mail = new Storage\Imap($this->params); + $delimiter = $mail->delimiter(); + $this->assertEquals(strlen($delimiter), 1); + } }