/** * @param string|SimpleXMLElement $content * * @return \Realejo\Ofx\SignOn */ public static function parse($content) { // Verifica se é um string if (is_string($content)) { $content = \Realejo\Ofx\Parser::makeXML($content); } $SignOn = new SignOn(); // Verifica se existe o bloco de SignOn $SIGNONMSGSRSV1 = $content->xpath('//SIGNONMSGSRSV1'); if (count($SIGNONMSGSRSV1) == 1) { // Verifica se exite a seção do request Signon $SONRQ = $content->xpath('//SIGNONMSGSRSV1/SONRQ'); if (count($SONRQ) == 1) { throw new \Exception('Signon request not implemented'); } // Verifica se exite a seção do response Signon $SONRS = $content->xpath('//SIGNONMSGSRSV1/SONRS'); if (count($SONRS) == 1) { $SONRS = $SONRS[0]; $response = new SignOnResponse(); $response->statusCode = (int) $SONRS->STATUS->CODE; $response->statusSeverity = $SONRS->STATUS->SEVERITY; $response->date = \Realejo\Ofx\Parser::parseDate($SONRS->DTSERVER); $response->language = $SONRS->LANGUAGE; $response->fiOrganization = $SONRS->FI->ORG; $response->fiUniqueId = $SONRS->FI->FID; $SignOn->setResponse($response); } // end if (count($SONRS) == 1) } //end if (count($SIGNONMSGSRSV1) == 1) return $SignOn; }
/** * Tests SignOn->setResponse()/SignOn->getResponse() */ public function testResponse() { $this->assertInstanceOf('Realejo\\Ofx\\SignOn', $this->SignOn->setResponse(new SignOnResponse())); $this->assertInstanceOf('Realejo\\Ofx\\SignOn\\Response', $this->SignOn->getResponse()); }