/**
  * Prepares return object for a list of emails and messages
  *
  * @param array $totMsg
  * @param integer $start
  * @param integer $limit
  * @return array
  */
 private function prepareObject($totMsg, $start, $limit, $total, $attributes = null)
 {
     $object = array("totalCount" => intval($total), "start" => $start, "messages" => array());
     MailContents::populateData($totMsg);
     for ($i = 0; $i < $limit; $i++) {
         if (isset($totMsg[$i])) {
             $msg = $totMsg[$i];
             if ($msg instanceof MailContent) {
                 /* @var $msg MailContent */
                 $properties = $this->getMailProperties($msg, $i);
                 $object["messages"][] = $properties;
             }
         }
     }
     return $object;
 }