/** * @param string $sFolderNameInUtf * @param string $sFolderParentFullNameRaw = '' * @param bool $bSubscribeOnCreation = true * * @return \MailSo\Mail\MailClient * * @throws \MailSo\Base\Exceptions\InvalidArgumentException */ public function FolderCreate($sFolderNameInUtf, $sFolderParentFullNameRaw = '', $bSubscribeOnCreation = true) { if (!\MailSo\Base\Validator::NotEmptyString($sFolderNameInUtf, true) || !\is_string($sFolderParentFullNameRaw)) { throw new \MailSo\Base\Exceptions\InvalidArgumentException(); } $sFolderNameInUtf = trim($sFolderNameInUtf); $aFolders = $this->oImapClient->FolderList('', 0 === \strlen(\trim($sFolderParentFullNameRaw)) ? 'INBOX' : $sFolderParentFullNameRaw); if (!\is_array($aFolders) || !isset($aFolders[0])) { // TODO throw new \MailSo\Mail\Exceptions\RuntimeException(0 === \strlen(trim($sFolderParentFullNameRaw)) ? 'Cannot get folder delimiter' : 'Cannot create folder in non-existen parent folder'); } $sDelimiter = $aFolders[0]->Delimiter(); if (0 < \strlen($sDelimiter) && 0 < \strlen(\trim($sFolderParentFullNameRaw))) { $sFolderParentFullNameRaw .= $sDelimiter; } $sFullNameRawToCreate = \MailSo\Base\Utils::ConvertEncoding($sFolderNameInUtf, \MailSo\Base\Enumerations\Charset::UTF_8, \MailSo\Base\Enumerations\Charset::UTF_7_IMAP); if (0 < \strlen($sDelimiter) && false !== \strpos($sFullNameRawToCreate, $sDelimiter)) { // TODO throw new \MailSo\Mail\Exceptions\RuntimeException('New folder name contain delimiter'); } $sFullNameRawToCreate = $sFolderParentFullNameRaw . $sFullNameRawToCreate; $this->oImapClient->FolderCreate($sFullNameRawToCreate); if ($bSubscribeOnCreation) { $this->oImapClient->FolderSubscribe($sFullNameRawToCreate); } return $this; }