Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Support returning IMAP delimiter. #41

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Storage/Imap.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class Imap extends AbstractStorage implements Folder\FolderInterface, Writable\W
*/
protected $currentFolder = '';

/**
* IMAP folder delimiter character
* @var string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is null too string|null

*/
protected $delimiter;

/**
* IMAP flags to constants translation
* @var array
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
7 changes: 7 additions & 0 deletions test/Storage/ImapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}