Пример #1
0
 /**
  * Tests Ofx->getHeaders()
  */
 public function testHeaders()
 {
     $headers = array('um array qualquer', 'por que o header não é nomalizado', 'deveria ser?', 'key' => 'value');
     $this->assertInstanceOf('\\Realejo\\Ofx\\Ofx', $this->Ofx->setHeaders($headers));
     $this->assertEquals($headers, $this->Ofx->getHeaders());
     $this->assertEquals($headers['key'], $this->Ofx->getHeader('key'));
     $this->assertNull($this->Ofx->getHeader('não existo'));
     $this->assertNull($this->Ofx->getHeader(null));
     $this->assertNull($this->Ofx->getHeader(false));
 }
Пример #2
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;
 }