protected static function _factoryFromXml(\DOMDocument $xmlDoc) { $elems = $xmlDoc->getElementsByTagName('order'); if ($elems->length != 1) { throw new \Exception('factoryFromXml order element not found', RequestAbstract::ERROR_FACTORY_BY_XML_ORDER_ELEM_NOT_FOUND); } $orderElem = $elems->item(0); $attr = $orderElem->attributes->getNamedItem('type'); if ($attr == null || strlen($attr->nodeValue) == 0) { throw new \Exception('factoryFromXml invalid payment request type=' . $attr->nodeValue, RequestAbstract::ERROR_FACTORY_BY_XML_ORDER_TYPE_ATTR_NOT_FOUND); } switch ($attr->nodeValue) { case RequestAbstract::PAYMENT_TYPE_CARD: $objPmReq = new Card(); break; case RequestAbstract::PAYMENT_TYPE_SMS: $objPmReq = new Sms(); break; case RequestAbstract::PAYMENT_TYPE_ADMIN: $objPmReq = new Admin(); break; case RequestAbstract::PAYMENT_TYPE_INFO: $objPmReq = new Info(); break; case RequestAbstract::PAYMENT_TYPE_CASH: $objPmReq = new Cash(); break; case RequestAbstract::PAYMENT_TYPE_TRANSFER: $objPmReq = new Transfer(); break; default: throw new \Exception('factoryFromXml invalid payment request type=' . $attr->nodeValue, RequestAbstract::ERROR_FACTORY_BY_XML_INVALID_TYPE); break; } $objPmReq->_loadFromXml($orderElem); return $objPmReq; }