Skip to content

Commit

Permalink
Ajuste ofxparser
Browse files Browse the repository at this point in the history
  • Loading branch information
cassioperin-bling committed May 28, 2020
1 parent 9a03d9b commit cc68e82
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 33 deletions.
4 changes: 2 additions & 2 deletions lib/OfxParser/Entities/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Status extends AbstractEntity
/**
* @var string[]
*/
private static $codes = [
const CODES = [
'0' => 'Success',
'2000' => 'General error',
'15000' => 'Must change USERPASS',
Expand Down Expand Up @@ -40,6 +40,6 @@ public function codeDesc()
{
// Cast code to string from SimpleXMLObject
$code = (string)$this->code;
return array_key_exists($code, self::$codes) ? self::$codes[$code] : '';
return array_key_exists($code, self::CODES) ? self::CODES[$code] : '';
}
}
4 changes: 2 additions & 2 deletions lib/OfxParser/Entities/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Transaction extends AbstractEntity
{
private static $types = [
const TYPES = [
'CREDIT' => 'Generic credit',
'DEBIT' => 'Generic debit',
'INT' => 'Interest earned or paid',
Expand Down Expand Up @@ -80,6 +80,6 @@ public function typeDesc()
{
// Cast SimpleXMLObject to string
$type = (string)$this->type;
return array_key_exists($type, self::$types) ? self::$types[$type] : '';
return array_key_exists($type, self::TYPES) ? self::TYPES[$type] : '';
}
}
23 changes: 0 additions & 23 deletions lib/OfxParser/Ofx.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,6 @@ class Ofx
*/
public $bankAccounts = [];

/**
* Only populated if there is only one bank account
* @var BankAccount|null
* @deprecated This will be removed in future versions
*/
public $bankAccount;

/**
* @param SimpleXMLElement $xml
* @throws \Exception
Expand All @@ -69,22 +62,6 @@ public function __construct(SimpleXMLElement $xml)
} elseif (isset($xml->CREDITCARDMSGSRSV1)) {
$this->bankAccounts = $this->buildCreditAccounts($xml);
}

// Set a helper if only one bank account
if (count($this->bankAccounts) === 1) {
$this->bankAccount = $this->bankAccounts[0];
}
}

/**
* Get the transactions that have been processed
*
* @return array
* @deprecated This will be removed in future versions
*/
public function getTransactions()
{
return $this->bankAccount->statement->transactions;
}

/**
Expand Down
5 changes: 0 additions & 5 deletions lib/OfxParser/Ofx/Investment.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ public function __construct(SimpleXMLElement $xml)
if (isset($xml->INVSTMTMSGSRSV1)) {
$this->bankAccounts = $this->buildAccounts($xml);
}

// Set a helper if only one bank account
if (count($this->bankAccounts) === 1) {
$this->bankAccount = $this->bankAccounts[0];
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/OfxParser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function loadFromFile($ofxFile)
public function loadFromString($ofxContent)
{
$ofxContent = str_replace(["\r\n", "\r"], "\n", $ofxContent);
$ofxContent = utf8_encode($ofxContent);
//$ofxContent = utf8_encode($ofxContent);

$sgmlStart = stripos($ofxContent, '<OFX>');
$ofxHeader = trim(substr($ofxContent, 0, $sgmlStart));
Expand Down

0 comments on commit cc68e82

Please sign in to comment.