public static function getPacketFromArray($arr) { if (isset($arr['from'], $arr['to'], $arr['type'], $arr['content'])) { $packet = new Packet(); $packet->setFrom($arr['from']); $packet->setTo($arr['to']); $packet->setType($arr['type']); $packet->setContent($arr['content']); return $packet; } else { return false; } }