Example #1
0
 /**
  * Sets the chats on a session instance
  *
  * @param  Sesssion  $session
  */
 protected function setChats(Session $session)
 {
     // No chats by default
     $chats = array();
     // Loop each chat (if any)
     /* @var $chat_xml \DOMNode */
     foreach ($this->dom->getElementsByTagName('Chat') as $chat_xml) {
         // Create new chat
         $chat = new Chat();
         // Set message
         $chat->setMessage($chat_xml->nodeValue);
         // Clone session date
         $date = clone $session->getDate();
         // Add the seconds to date, ignoring any decimals
         $date->modify(sprintf('+%d seconds', (int) $chat_xml->getAttribute('et')));
         // Set real estimated seconds
         $chat->setElapsedSeconds((double) $chat_xml->getAttribute('et'));
         // Add date to chat
         $chat->setDate($date);
         // Add chat to chats
         $chats[] = $chat;
     }
     // Set chats on session
     $session->setChats($chats);
 }