Example #1
0
 /**
  * @param array $array
  * @param bool $cast
  * @return Message|TextMessage|PhotoMessage
  */
 public static function create(array $array, $cast = true)
 {
     if ($cast and isset($array['text'])) {
         return TextMessage::create($array);
     }
     if ($cast and isset($array['photo'])) {
         return PhotoMessage::create($array);
     }
     return new Message(intval($array['message_id']), intval($array['date']), Chat::create($array['chat']), isset($array['from']) ? User::create($array['from']) : null, isset($array['forward_from']) ? User::create($array['forward_from']) : null, isset($array['forward_date']) ? intval($array['forward_date']) : null, isset($array['reply_to_message']) ? Message::create($array['reply_to_message']) : null);
 }
Example #2
0
 /**
  * @param array $array
  * @return PhotoMessage
  */
 public static function create(array $array)
 {
     return new PhotoMessage(Message::create($array, false), array_map(function ($photoSize) {
         return PhotoSize::create($photoSize);
     }, $array['photo']));
 }
Example #3
0
 public static function create(array $array)
 {
     return new Update(intval($array['update_id']), isset($array['message']) ? Message::create($array['message']) : null);
 }