Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4 from loweoj/master
Browse files Browse the repository at this point in the history
Finish and include new tests.
  • Loading branch information
asgrim committed Jul 21, 2014
2 parents 0480a80 + 4a5de44 commit e9b92b6
Show file tree
Hide file tree
Showing 18 changed files with 467 additions and 161 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

.idea
.DS_Store
vendor
36 changes: 30 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
OFX parser bundle
OFX Parser
=================

##Fork'd
This is a fork of [grimfor/ofxparser](https://github.com/Grimfor/ofxparser) made to be framework independent. The source repo was designed for Symfony 2 framework, so credit should be given where credit due!
OFX Parser is a PHP library designed to parse an OFX file downloaded from a financial institution into simple PHP objects.

It supports multiple Bank Accounts, the required "Sign On" response, and recognises OFX timestamps.


##Installation

Add in your composer.json:
Simply require this package in your composer.json:

```js
{
Expand All @@ -16,8 +18,30 @@ Add in your composer.json:
}
```

Now tell composer to download the bundle by running the command:
Then update composer:

``` bash
```bash
$ php composer.phar update asgrim/ofxparser
```

## Usage
You can access the nodes in your OFX file as follows:

```php
$OfxParser = new \OfxParser\Parser;
$Ofx = $OfxParser->loadFromFile('/path/to/your/bankstatement.ofx');

// Get the statement start and end dates
$startDate = $Ofx->BankAccount->Statement->startDate;
$endDate = $Ofx->BankAccount->Statement->endDate;

// Get the statements for the current bank account
$transactions = $Ofx->BankAccount->Statement->transactions;
```

Most common nodes are support. If you come across an inaccessible node in your OFX file, please submit a pull request!


## Fork & Credits
This is a fork of [grimfor/ofxparser](https://github.com/Grimfor/ofxparser) made to be framework independent. The source repo was designed for Symfony 2 framework, so credit should be given where credit due!
Heavily refactored by [Oliver Lowe](https://github.com/loweoj) and loosely based on the ruby [ofx-parser by Andrew A. Smith](https://github.com/aasmith/ofx-parser).
6 changes: 5 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@
"name": "James Titcumb",
"email": "[email protected]",
"homepage": "http://www.jamestitcumb.com/"
},
{
"name": "Oliver Lowe",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.3"
"php": ">=5.4"
},
"autoload": {
"psr-0": { "OfxParser": "lib/" }
Expand Down
2 changes: 1 addition & 1 deletion lib/OfxParser/Entities/AbstractEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ abstract class AbstractEntity
* Allow functions to be called as properties
* to unify the API
*
* @param $name [description]
* @param $name
* @return method | bool
*/
public function __get($name)
Expand Down
11 changes: 0 additions & 11 deletions lib/OfxParser/Entities/Account.php

This file was deleted.

4 changes: 2 additions & 2 deletions lib/OfxParser/Entities/AccountInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

class AccountInfo extends AbstractEntity
{
public $Desc;
public $Number;
public $desc;
public $number;
}
13 changes: 5 additions & 8 deletions lib/OfxParser/Entities/BankAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@

namespace OfxParser\Entities;

class BankAccount extends Account
class BankAccount extends AbstractEntity
{
protected $types = array(
'CHECKING',
'SAVINGS',
'MONEYMRKT',
'CREDITLINE'
);

public $accountNumber;
public $accountType;
public $balance;
public $balanceDate;
public $routingNumber;
public $statement;
public $transactionUid;
}
11 changes: 0 additions & 11 deletions lib/OfxParser/Entities/CreditAccount.php

This file was deleted.

14 changes: 11 additions & 3 deletions lib/OfxParser/Entities/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,29 @@

class Status extends AbstractEntity
{
protected $codes= array (
protected $codes= [
'0' => 'Success',
'2000' => 'General error',
'15000' => 'Must change USERPASS',
'15500' => 'Signon invalid',
'15501' => 'Customer account already in use',
'15502' => 'USERPASS Lockout'
);
];

public $code;
public $severity;
public $message;

/**
* Get the associated code description
*
* @return string
*/
public function codeDesc()
{
return isset($this->codes[$this->code]) ? $this->codes[$this->code] : '';
// Cast code to string from SimpleXMLObject
$code = (string) $this->code;
return isset($this->codes[$code]) ? $this->codes[$code] : '';
}

}
13 changes: 11 additions & 2 deletions lib/OfxParser/Entities/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,18 @@ class Transaction extends AbstractEntity
public $uniqueId;
public $name;
public $memo;
public $sic;
public $checkNumber;

public function TypeDescription()
/**
* Get the associated type description
*
* @return string
*/
public function typeDesc()
{
return isset($this->types[$this->type]) ? $this->types[$this->type] : '';
// Cast SimpleXMLObject to string
$type = (string) $this->type;
return isset($this->types[$type]) ? $this->types[$type] : '';
}
}
Loading

0 comments on commit e9b92b6

Please sign in to comment.