Move ResponseCollection functions to their command functions

This commit is contained in:
djmaze 2021-11-22 23:03:05 +01:00
parent 299ec7faf8
commit afcd76adbf
4 changed files with 269 additions and 276 deletions

View file

@ -0,0 +1,180 @@
<?php
/*
* This file is part of MailSo.
*
* (c) 2014 Usenko Timur
* (c) 2021 DJMaze
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace MailSo\Imap\Commands;
use MailSo\Imap\ResponseCollection;
use MailSo\Imap\Enumerations\ResponseType;
/**
* @category MailSo
* @package Imap
*/
trait Messages
{
/**
* See https://tools.ietf.org/html/rfc5256
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleSort(array $aSortTypes, string $sSearchCriterias = 'ALL', bool $bReturnUid = true) : array
{
$oSort = new \MailSo\Imap\Requests\SORT($this);
$oSort->sCriterias = $sSearchCriterias;
$oSort->bUid = $bReturnUid;
$oSort->aSortTypes = $aSortTypes;
$oResponseCollection = $oSort->SendRequestGetResponse();
$aReturn = array();
foreach ($oResponseCollection as $oResponse) {
$iOffset = ($bReturnUid && 'UID' === $oResponse->StatusOrIndex && !empty($oResponse->ResponseList[2]) && 'SORT' === $oResponse->ResponseList[2]) ? 1 : 0;
if (ResponseType::UNTAGGED === $oResponse->ResponseType
&& ('SORT' === $oResponse->StatusOrIndex || $iOffset)
&& \is_array($oResponse->ResponseList)
&& 2 < \count($oResponse->ResponseList))
{
$iLen = \count($oResponse->ResponseList);
for ($iIndex = 2 + $iOffset; $iIndex < $iLen; ++$iIndex) {
$aReturn[] = (int) $oResponse->ResponseList[$iIndex];
}
}
}
return $aReturn;
}
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleESearch(string $sSearchCriterias = 'ALL', array $aSearchReturn = null, bool $bReturnUid = true, string $sCharset = '', string $sLimit = '') : array
{
$oESearch = new \MailSo\Imap\Requests\ESEARCH($this);
$oESearch->sCriterias = $sSearchCriterias;
$oESearch->aReturn = $aSearchReturn;
$oESearch->bUid = $bReturnUid;
$oESearch->sLimit = $sLimit;
$oESearch->sCharset = $sCharset;
return $this->getSimpleESearchOrESortResult($oESearch->SendRequestGetResponse(), $bReturnUid);
}
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleESort(array $aSortTypes, string $sSearchCriterias = 'ALL', array $aSearchReturn = ['ALL'], bool $bReturnUid = true, string $sLimit = '') : array
{
$oSort = new \MailSo\Imap\Requests\SORT($this);
$oSort->sCriterias = $sSearchCriterias;
$oSort->bUid = $bReturnUid;
$oSort->aSortTypes = $aSortTypes;
$oSort->aReturn = $aSearchReturn ?: ['ALL'];
$oSort->sLimit = $sLimit;
return $this->getSimpleESearchOrESortResult($oSort->SendRequestGetResponse(), $bReturnUid);
}
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleSearch(string $sSearchCriterias = 'ALL', bool $bReturnUid = true, string $sCharset = '') : array
{
$aRequest = array();
if (\strlen($sCharset)) {
$aRequest[] = 'CHARSET';
$aRequest[] = \strtoupper($sCharset);
}
$aRequest[] = !\strlen($sSearchCriterias) || '*' === $sSearchCriterias ? 'ALL' : $sSearchCriterias;
$sCont = $this->SendRequest($bReturnUid ? 'UID SEARCH' : 'SEARCH', $aRequest, true);
$oResult = $this->getResponse();
if ('' !== $sCont) {
$oItem = $oResult->getLast();
if ($oItem && ResponseType::CONTINUATION === $oItem->ResponseType) {
$aParts = \explode("\r\n", $sCont);
foreach ($aParts as $sLine) {
$this->sendRaw($sLine);
$oResult = $this->getResponse();
$oItem = $oResult->getLast();
if ($oItem && ResponseType::CONTINUATION === $oItem->ResponseType) {
continue;
}
}
}
}
$aReturn = array();
foreach ($oResult as $oResponse) {
$iOffset = ($bReturnUid && 'UID' === $oResponse->StatusOrIndex && !empty($oResponse->ResponseList[2]) && 'SEARCH' === $oResponse->ResponseList[2]) ? 1 : 0;
if (ResponseType::UNTAGGED === $oResponse->ResponseType
&& ('SEARCH' === $oResponse->StatusOrIndex || $iOffset)
&& \is_array($oResponse->ResponseList)
&& 2 < \count($oResponse->ResponseList))
{
$iLen = \count($oResponse->ResponseList);
for ($iIndex = 2 + $iOffset; $iIndex < $iLen; ++$iIndex) {
$aReturn[] = (int) $oResponse->ResponseList[$iIndex];
}
}
}
return \array_reverse($aReturn);
}
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleThread(string $sSearchCriterias = 'ALL', bool $bReturnUid = true, string $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8) : array
{
$oThread = new \MailSo\Imap\Requests\THREAD($this);
$oThread->sCriterias = $sSearchCriterias;
$oThread->sCharset = $sCharset;
$oThread->bUid = $bReturnUid;
return $oThread->SendRequestGetResponse();
}
private function getSimpleESearchOrESortResult(ResponseCollection $oResponseCollection, bool $bReturnUid) : array
{
$sRequestTag = $this->getCurrentTag();
$aResult = array();
foreach ($oResponseCollection as $oResponse) {
if (ResponseType::UNTAGGED === $oResponse->ResponseType
&& ('ESEARCH' === $oResponse->StatusOrIndex || 'SORT' === $oResponse->StatusOrIndex)
&& \is_array($oResponse->ResponseList)
&& isset($oResponse->ResponseList[2][1])
&& 'TAG' === $oResponse->ResponseList[2][0] && $sRequestTag === $oResponse->ResponseList[2][1]
&& (!$bReturnUid || (!empty($oResponse->ResponseList[3]) && 'UID' === $oResponse->ResponseList[3]))
)
{
$i = \count($oResponse->ResponseList) - 1;
while (3 < --$i) {
$sItem = $oResponse->ResponseList[$i];
switch ($sItem)
{
case 'ALL':
case 'MAX':
case 'MIN':
case 'COUNT':
$aResult[$sItem] = $oResponse->ResponseList[$i + 1];
break;
}
}
}
}
return $aResult;
}
}

View file

@ -19,6 +19,7 @@ class ImapClient extends \MailSo\Net\NetClient
{
use Traits\ResponseParser;
// use Commands\ACL;
use Commands\Messages;
use Commands\Metadata;
use Commands\Quota;
@ -333,13 +334,22 @@ class ImapClient extends \MailSo\Net\NetClient
*/
public function GetNamespace() : ?NamespaceResult
{
if (!$this->IsSupported('NAMESPACE'))
{
if (!$this->IsSupported('NAMESPACE')) {
return null;
}
try {
return $this->SendRequestGetResponse('NAMESPACE')->getNamespaceResult();
$oResponseCollection = $this->SendRequestGetResponse('NAMESPACE');
foreach ($oResponseCollection as $oResponse) {
if (Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType
&& 'NAMESPACE' === $oResponse->StatusOrIndex)
{
$oReturn = new NamespaceResult;
$oReturn->InitByImapResponse($oResponse);
return $oReturn;
}
}
throw new Exceptions\ResponseException;
} catch (\Throwable $e) {
$this->writeLogException($e, \MailSo\Log\Enumerations\Type::ERROR);
throw $e;
@ -489,7 +499,7 @@ class ImapClient extends \MailSo\Net\NetClient
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
private function specificFolderList(bool $bIsSubscribeList, string $sParentFolderName = '', string $sListPattern = '*', bool $bUseListStatus = false) : array
protected function specificFolderList(bool $bIsSubscribeList, string $sParentFolderName = '', string $sListPattern = '*', bool $bUseListStatus = false) : array
{
$sCmd = 'LIST';
@ -815,114 +825,17 @@ class ImapClient extends \MailSo\Net\NetClient
$this->aFetchCallbacks = array();
}
return $oResult->getFetchResult($this->oLogger);
}
/**
* See https://tools.ietf.org/html/rfc5256
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleSort(array $aSortTypes, string $sSearchCriterias = 'ALL', bool $bReturnUid = true) : array
{
$oSort = new Requests\SORT($this);
$oSort->sCriterias = $sSearchCriterias;
$oSort->bUid = $bReturnUid;
$oSort->aSortTypes = $aSortTypes;
return $oSort->SendRequestGetResponse()
->getMessageSimpleSortResult($bReturnUid);
}
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleESearch(string $sSearchCriterias = 'ALL', array $aSearchReturn = null, bool $bReturnUid = true, string $sCharset = '', string $sLimit = '') : array
{
$oESearch = new Requests\ESEARCH($this);
$oESearch->sCriterias = $sSearchCriterias;
$oESearch->aReturn = $aSearchReturn;
$oESearch->bUid = $bReturnUid;
$oESearch->sLimit = $sLimit;
$oESearch->sCharset = $sCharset;
return $oESearch->SendRequestGetResponse()
->getSimpleESearchOrESortResult($this->getCurrentTag(), $bReturnUid);
}
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleESort(array $aSortTypes, string $sSearchCriterias = 'ALL', array $aSearchReturn = ['ALL'], bool $bReturnUid = true, string $sLimit = '') : array
{
$oSort = new Requests\SORT($this);
$oSort->sCriterias = $sSearchCriterias;
$oSort->bUid = $bReturnUid;
$oSort->aSortTypes = $aSortTypes;
$oSort->aReturn = $aSearchReturn ?: ['ALL'];
$oSort->sLimit = $sLimit;
return $oSort->SendRequestGetResponse()
->getSimpleESearchOrESortResult($this->getCurrentTag(), $bReturnUid);
}
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleSearch(string $sSearchCriterias = 'ALL', bool $bReturnUid = true, string $sCharset = '') : array
{
$aRequest = array();
if (\strlen($sCharset))
{
$aRequest[] = 'CHARSET';
$aRequest[] = \strtoupper($sCharset);
}
$aRequest[] = !\strlen($sSearchCriterias) || '*' === $sSearchCriterias ? 'ALL' : $sSearchCriterias;
$sCont = $this->SendRequest($bReturnUid ? 'UID SEARCH' : 'SEARCH', $aRequest, true);
$oResult = $this->getResponse();
if ('' !== $sCont)
{
$oItem = $oResult->getLast();
if ($oItem && Enumerations\ResponseType::CONTINUATION === $oItem->ResponseType)
{
$aParts = explode("\r\n", $sCont);
foreach ($aParts as $sLine)
{
$this->sendRaw($sLine);
$oResult = $this->getResponse();
$oItem = $oResult->getLast();
if ($oItem && Enumerations\ResponseType::CONTINUATION === $oItem->ResponseType)
{
continue;
}
$aReturn = array();
foreach ($oResult as $oResponse) {
if (FetchResponse::IsValidFetchImapResponse($oResponse)) {
if (FetchResponse::IsNotEmptyFetchImapResponse($oResponse)) {
$aReturn[] = new FetchResponse($oResponse);
} else if ($this->oLogger) {
$this->oLogger->Write('Skipped Imap Response! ['.$oResponse->ToLine().']', \MailSo\Log\Enumerations\Type::NOTICE);
}
}
}
return $oResult->getMessageSimpleSearchResult($bReturnUid);
}
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageSimpleThread(string $sSearchCriterias = 'ALL', bool $bReturnUid = true, string $sCharset = \MailSo\Base\Enumerations\Charset::UTF_8) : array
{
$oThread = new Requests\THREAD($this);
$oThread->sCriterias = $sSearchCriterias;
$oThread->sCharset = $sCharset;
$oThread->bUid = $bReturnUid;
return $oThread->SendRequestGetResponse()
->getMessageSimpleThreadResult($bReturnUid);
return $aReturn;
}
/**
@ -1115,7 +1028,7 @@ class ImapClient extends \MailSo\Net\NetClient
return '';
}
private function secureRequestParams(string $sCommand, array $aParams) : ?array
protected function secureRequestParams(string $sCommand, array $aParams) : ?array
{
if ('LOGIN' === $sCommand && isset($aParams[1])) {
$aParams[1] = '"********"';
@ -1135,7 +1048,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $this->getResponse();
}
private function getResponseValue(ResponseCollection $oResponseCollection, int $type = 0) : string
protected function getResponseValue(ResponseCollection $oResponseCollection, int $type = 0) : string
{
$oResponse = $oResponseCollection->getLast();
if ($oResponse && (!$type || $type === $oResponse->ResponseType)) {
@ -1161,7 +1074,7 @@ class ImapClient extends \MailSo\Net\NetClient
* @throws \MailSo\Imap\Exceptions\InvalidResponseException
* @throws \MailSo\Imap\Exceptions\NegativeResponseException
*/
private function streamResponse(string $sEndTag = null) : void
protected function streamResponse(string $sEndTag = null) : void
{
try {
if (\is_resource($this->ConnectionResource())) {
@ -1184,7 +1097,7 @@ class ImapClient extends \MailSo\Net\NetClient
}
}
private function getResponse(string $sEndTag = null) : ResponseCollection
protected function getResponse(string $sEndTag = null) : ResponseCollection
{
try {
$oResult = new ResponseCollection;
@ -1225,7 +1138,7 @@ class ImapClient extends \MailSo\Net\NetClient
return $oResult;
}
private function prepareParamLine(array $aParams = array()) : string
protected function prepareParamLine(array $aParams = array()) : string
{
$sReturn = '';
foreach ($aParams as $mParamItem)
@ -1242,13 +1155,13 @@ class ImapClient extends \MailSo\Net\NetClient
return $sReturn;
}
private function getNewTag() : string
protected function getNewTag() : string
{
++$this->iTagCount;
return $this->getCurrentTag();
}
private function getCurrentTag() : string
protected function getCurrentTag() : string
{
return self::TAG_PREFIX.$this->iTagCount;
}

View file

@ -36,22 +36,23 @@ class THREAD extends Request
$this->sAlgorithm = 'ORDEREDSUBJECT';
} else {
$oImapClient->writeLogException(
new RuntimeException('THREAD is not supported'),
Type::ERROR, true);
new \MailSo\Imap\Exceptions\RuntimeException('THREAD is not supported'),
\MailSo\Log\Enumerations\Type::ERROR, true);
}
parent::__construct($oImapClient);
}
public function SendRequestGetResponse() : \MailSo\Imap\ResponseCollection
public function SendRequestGetResponse() : array
{
if (!$this->oImapClient->IsSupported(\strtoupper("THREAD={$this->sAlgorithm}"))) {
$this->oImapClient->writeLogException(
new Exceptions\RuntimeException("THREAD={$this->sAlgorithm} is not supported"),
new \MailSo\Imap\Exceptions\RuntimeException("THREAD={$this->sAlgorithm} is not supported"),
\MailSo\Log\Enumerations\Type::ERROR, true);
}
$aRequest = array();
$aRequest[] = $this->sAlgorithm;
$aRequest = array(
$this->sAlgorithm
);
$sSearchCriterias = (\strlen($this->sCriterias) && '*' !== $this->sCriterias) ? $this->sCriterias : 'ALL';
@ -62,9 +63,61 @@ class THREAD extends Request
$aRequest[] = \strtoupper($this->sCharset);
$aRequest[] = $sSearchCriterias;
return $this->oImapClient->SendRequestGetResponse(
$oResponseCollection = $this->oImapClient->SendRequestGetResponse(
($this->bUid ? 'UID THREAD' : 'THREAD'),
$aRequest
);
$aReturn = array();
foreach ($oResponseCollection as $oResponse) {
$iOffset = ($bReturnUid && 'UID' === $oResponse->StatusOrIndex && !empty($oResponse->ResponseList[2]) && 'THREAD' === $oResponse->ResponseList[2]) ? 1 : 0;
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType
&& ('THREAD' === $oResponse->StatusOrIndex || $iOffset)
&& \is_array($oResponse->ResponseList)
&& 2 < \count($oResponse->ResponseList))
{
$iLen = \count($oResponse->ResponseList);
for ($iIndex = 2 + $iOffset; $iIndex < $iLen; ++$iIndex) {
$aNewValue = $this->validateThreadItem($oResponse->ResponseList[$iIndex]);
if (\is_array($aNewValue)) {
$aReturn[] = $aNewValue;
}
}
}
}
return $aReturn;
}
/**
* @param mixed $mValue
*
* @return mixed
*/
private function validateThreadItem($mValue)
{
$mResult = false;
if (\is_numeric($mValue)) {
$mResult = (int) $mValue;
if (0 >= $mResult) {
$mResult = false;
}
} else if (\is_array($mValue)) {
if (1 === \count($mValue) && \is_numeric($mValue[0])) {
$mResult = (int) $mValue[0];
if (0 >= $mResult) {
$mResult = false;
}
} else {
$mResult = array();
foreach ($mValue as $mValueItem) {
$mTemp = $this->validateThreadItem($mValueItem);
if (false !== $mTemp) {
$mResult[] = $mTemp;
}
}
}
}
return $mResult;
}
}

View file

@ -73,21 +73,6 @@ class ResponseCollection extends \MailSo\Base\Collection
return null;
}
public function getFetchResult($oLogger) : array
{
$aReturn = array();
foreach ($this as $oResponse) {
if (FetchResponse::IsValidFetchImapResponse($oResponse)) {
if (FetchResponse::IsNotEmptyFetchImapResponse($oResponse)) {
$aReturn[] = new FetchResponse($oResponse);
} else if ($oLogger) {
$oLogger->Write('Skipped Imap Response! ['.$oResponse->ToLine().']', \MailSo\Log\Enumerations\Type::NOTICE);
}
}
}
return $aReturn;
}
public function getFoldersResult(string $sStatus, ImapClient $oImapClient) : array
{
$aReturn = array();
@ -159,142 +144,4 @@ class ResponseCollection extends \MailSo\Base\Collection
return $aReturn;
}
public function getMessageSimpleSearchResult(bool $bReturnUid) : array
{
$aReturn = array();
foreach ($this as $oResponse) {
$iOffset = ($bReturnUid && 'UID' === $oResponse->StatusOrIndex && !empty($oResponse->ResponseList[2]) && 'SEARCH' === $oResponse->ResponseList[2]) ? 1 : 0;
if (Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType
&& ('SEARCH' === $oResponse->StatusOrIndex || $iOffset)
&& \is_array($oResponse->ResponseList)
&& 2 < \count($oResponse->ResponseList))
{
$iLen = \count($oResponse->ResponseList);
for ($iIndex = 2 + $iOffset; $iIndex < $iLen; ++$iIndex) {
$aReturn[] = (int) $oResponse->ResponseList[$iIndex];
}
}
}
return \array_reverse($aReturn);
}
public function getMessageSimpleSortResult(bool $bReturnUid) : array
{
$aReturn = array();
foreach ($this as $oResponse) {
$iOffset = ($bReturnUid && 'UID' === $oResponse->StatusOrIndex && !empty($oResponse->ResponseList[2]) && 'SORT' === $oResponse->ResponseList[2]) ? 1 : 0;
if (Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType
&& ('SORT' === $oResponse->StatusOrIndex || $iOffset)
&& \is_array($oResponse->ResponseList)
&& 2 < \count($oResponse->ResponseList))
{
$iLen = \count($oResponse->ResponseList);
for ($iIndex = 2 + $iOffset; $iIndex < $iLen; ++$iIndex) {
$aReturn[] = (int) $oResponse->ResponseList[$iIndex];
}
}
}
return $aReturn;
}
public function getMessageSimpleThreadResult(bool $bReturnUid) : array
{
$aReturn = array();
foreach ($this as $oResponse) {
$iOffset = ($bReturnUid && 'UID' === $oResponse->StatusOrIndex && !empty($oResponse->ResponseList[2]) && 'THREAD' === $oResponse->ResponseList[2]) ? 1 : 0;
if (Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType
&& ('THREAD' === $oResponse->StatusOrIndex || $iOffset)
&& \is_array($oResponse->ResponseList)
&& 2 < \count($oResponse->ResponseList))
{
$iLen = \count($oResponse->ResponseList);
for ($iIndex = 2 + $iOffset; $iIndex < $iLen; ++$iIndex) {
$aNewValue = $this->validateThreadItem($oResponse->ResponseList[$iIndex]);
if (\is_array($aNewValue)) {
$aReturn[] = $aNewValue;
}
}
}
}
return $aReturn;
}
public function getNamespaceResult() : NamespaceResult
{
foreach ($this as $oResponse) {
if (Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType &&
'NAMESPACE' === $oResponse->StatusOrIndex)
{
$oReturn = new NamespaceResult;
$oReturn->InitByImapResponse($oResponse);
return $oReturn;
}
}
throw new Exceptions\ResponseException;
}
public function getSimpleESearchOrESortResult(string $sRequestTag, bool $bReturnUid) : array
{
$aResult = array();
foreach ($this as $oResponse) {
if (Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType
&& ('ESEARCH' === $oResponse->StatusOrIndex || 'SORT' === $oResponse->StatusOrIndex)
&& \is_array($oResponse->ResponseList)
&& isset($oResponse->ResponseList[2][1])
&& 'TAG' === $oResponse->ResponseList[2][0] && $sRequestTag === $oResponse->ResponseList[2][1]
&& (!$bReturnUid || (!empty($oResponse->ResponseList[3]) && 'UID' === $oResponse->ResponseList[3]))
)
{
$i = \count($oResponse->ResponseList) - 1;
while (3 < --$i) {
$sItem = $oResponse->ResponseList[$i];
switch ($sItem)
{
case 'ALL':
case 'MAX':
case 'MIN':
case 'COUNT':
$aResult[$sItem] = $oResponse->ResponseList[$i + 1];
break;
}
}
}
}
return $aResult;
}
/**
* @param mixed $mValue
*
* @return mixed
*/
private function validateThreadItem($mValue)
{
$mResult = false;
if (\is_numeric($mValue)) {
$mResult = (int) $mValue;
if (0 >= $mResult) {
$mResult = false;
}
} else if (\is_array($mValue)) {
if (1 === \count($mValue) && \is_numeric($mValue[0])) {
$mResult = (int) $mValue[0];
if (0 >= $mResult) {
$mResult = false;
}
} else {
$mResult = array();
foreach ($mValue as $mValueItem) {
$mTemp = $this->validateThreadItem($mValueItem);
if (false !== $mTemp) {
$mResult[] = $mTemp;
}
}
}
}
return $mResult;
}
}