/**
  * @param \SimpleXMLElement $xml
  *
  * @return \Searchperience\Api\Client\Domain\Document\Document[]
  */
 protected function buildUrlQueueItemsFromXml(\SimpleXMLElement $xml)
 {
     $urlQueueArray = new UrlQueueItemCollection();
     if ($xml->totalCount instanceof \SimpleXMLElement) {
         $urlQueueArray->setTotalCount((int) $xml->totalCount->__toString());
     }
     $urlQueues = $xml->xpath('item');
     foreach ($urlQueues as $urlQueue) {
         $urlQueueAttributeArray = (array) $urlQueue->attributes();
         $urlQueueObject = new \Searchperience\Api\Client\Domain\UrlQueueItem\UrlQueueItem();
         $urlQueueObject->__setProperty('documentId', (int) $urlQueueAttributeArray['@attributes']['id']);
         $urlQueueObject->__setProperty('url', (string) $urlQueue->url);
         $urlQueueObject->__setProperty('deleted', (bool) (int) $urlQueue->deleted);
         $urlQueueObject->__setProperty('failCount', (int) $urlQueue->failCount);
         $urlQueueObject->__setProperty('processingThreadId', (int) $urlQueue->processingThreadId);
         if (trim($urlQueue->processingStartTime) != '') {
             //we assume that the restapi always return y-m-d H:i:s in the utc format
             $processingStartTime = $this->dateTimeService->getDateTimeFromApiDateString($urlQueue->processingStartTime);
             if ($processingStartTime instanceof \DateTime) {
                 $urlQueueObject->__setProperty('processingStartTime', $processingStartTime);
             }
         }
         $urlQueueObject->__setProperty('lastError', (string) $urlQueue->lastError);
         $urlQueueObject->__setProperty('priority', (int) $urlQueue->priority);
         $urlQueueObject->afterReconstitution();
         $urlQueueArray->append($urlQueueObject);
     }
     return $urlQueueArray;
 }
 /**
  * @param UrlQueueItemCollection $urqueues
  * @return UrlQueueItemCollection
  */
 private function decorateUrlQueueItems(UrlQueueItemCollection $urqueues)
 {
     $newCollection = new UrlQueueItemCollection();
     $newCollection->setTotalCount($urqueues->getTotalCount());
     foreach ($urqueues as $urqueue) {
         $newCollection->append($this->checkTypeAndDecorate($urqueue));
     }
     return $newCollection;
 }