Example #1
0
 /**
  * @param string $content
  *
  * @return \Realejo\Ofx\Ofx
  */
 public static function createFromString($content)
 {
     $content = explode('<OFX>', $content);
     // Cria o objeto Ofx
     $ofx = new Ofx();
     // Define os headers do OFX
     $ofx->setHeaders(self::parseHeaders(trim($content[0])));
     // Verifica se há mais coisda além do header
     if (!isset($content[1])) {
         return $ofx;
     }
     // Define o conteúdo SGML do OFX
     $xmlContent = '<OFX>' . $content[1];
     // Fix encoding
     $currentEncoding = $ofx->getHeader('ENCODING');
     if ($currentEncoding == 'USASCII') {
         $currentEncoding = 'ASCII';
     }
     if (!empty($currentEncoding) && $currentEncoding !== 'UTF-8') {
         $xmlContent = mb_convert_encoding($xmlContent, 'UTF-8', $currentEncoding);
     }
     // Cria o XML
     $xml = self::makeXML($xmlContent);
     $parse = SignOn::parse($xml);
     if (!empty($parse)) {
         $ofx->setSignOn($parse);
     }
     //$ofx->setSignup($this->parseSignup());
     $parse = BankingParser::parse($xml);
     if (!empty($parse)) {
         $ofx->setBanking($parse);
     }
     //$ofx->setInvestment($this->parseInvestment());
     //$ofx->setInterbank($this->parseInterbank());
     //$ofx->setWireFundsTransfers($this->parseWireFundsTransfers());
     //$ofx->setPayments($this->parsePayments());
     //$ofx->setGeneralEmail($this->parseGeneralEmail());
     //$ofx->setInvestmentSecurity($this->parseInvestmentSecurity());
     //$ofx->setFIProfile($this->parseFIProfile());
     return $ofx;
 }
Example #2
0
 /**
  * Tests Getters ans Setters
  */
 public function testSettersGetters()
 {
     $this->assertInstanceOf('\\Realejo\\Ofx\\Ofx', $this->Ofx->setSignOn(new SignOn()));
     $this->assertInstanceOf('\\Realejo\\Ofx\\SignOn', $this->Ofx->getSignOn());
 }