Skip to content

Commit

Permalink
Implemented missing entities, Implemented parsers, and normalizer for…
Browse files Browse the repository at this point in the history
… ofx content string
  • Loading branch information
wesleyguirra committed Feb 25, 2024
1 parent 25beab3 commit f7b9e25
Show file tree
Hide file tree
Showing 39 changed files with 3,064 additions and 317 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
indent_style = space
charset = utf-8

# 4 space indentation
[*.php]
indent_style = space
indent_size = 4
86 changes: 86 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .idea/phpunit.xml

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright (c) 2024 The Authors of ofx-php-parser

Wes Guirra - wesguirra@icloud.com

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# OFX PHP Parser
This project consists of a PHP parser for OFX (Open Financial Exchange) files, implemented using PHP 8.2. Our aim is to make the process of importing OFX files as straightforward and hassle-free as possible.

## Installation
Simply require the package using [Composer](https://getcomposer.org/):

```bash
$ composer require endeken/ofx-php-parser
```

## Usage
This project primarily revolves around the `OFX` class in the `Endeken\OFX` namespace. This class provides a static function `parse()` which is used to parse OFX data and return the parsed information. Here is a basic usage example:
```php
<?php

require 'vendor/autoload.php';

use Endeken\OFX;

try {
// Load the OFX data
$ofxData = file_get_contents('path_to_your_ofx_file.ofx');

// Parse the OFX data
$parsedData = OFX::parse($ofxData);

// $parsedData is an instance of OFXData which gives you access to all parsed data

// Access the sign-on status code
$statusCode = $parsedData->signOn->status->code;

// Accessing bank accounts data
$bankAccounts = $parsedData->bankAccounts;
foreach($bankAccounts as $account) {
echo 'Account ID: ' .$account->accountNumber . PHP_EOL;
echo 'Bank ID: ' .$account->routingNumber . PHP_EOL;

// Loop through each transaction
foreach ($account->statement->transactions as $transaction) {
echo 'Transaction Type: ' . $transaction->type . PHP_EOL;
echo 'Date: ' . $transaction->date . PHP_EOL;
echo 'Amount: ' . $transaction->amount . PHP_EOL;
}
}

} catch (Exception $e) {
echo 'An error occurred: ' . $e->getMessage();
}
```

## Acknowledgements

This library is a standalone project, however it is heavily influenced by the work done in the [asgrim/ofxparser](https://github.com/asgrim/ofxparser) which itself is a fork of [grimfor/ofxparser](https://github.com/grimfor/ofxparser). We would like to acknowledge the contributions made by the developers of these projects. Our intent was not to simply fork the project, but to build upon their work while taking the library in a slightly different direction to better serve our purposes.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
}
],
"require": {
"ext-simplexml": "*"
"ext-simplexml": "*",
"ext-http": "*",
"ext-mbstring": "*",
"ext-libxml": "*"
},
"autoload": {
"psr-4": {
Expand Down
22 changes: 22 additions & 0 deletions src/AccountInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Endeken\OFX;

class AccountInfo
{
/**
* @var string $description The account description
*/
public string $description;

/**
* @var string $number The account number.
*/
public string $number;

public function __construct(string $description, string $number)
{
$this->description = $description;
$this->number = $number;
}
}
69 changes: 69 additions & 0 deletions src/BankAccount.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace Endeken\OFX;

use DateTime;

class BankAccount
{
/**
* @var string
*/
public string $accountNumber;

/**
* @var string
*/
public string $accountType;

/**
* @var string
*/
public string $balance;

/**
* @var DateTime
*/
public DateTime $balanceDate;

/**
* @var string
*/
public string $routingNumber;

/**
* @var Statement
*/
public Statement $statement;

/**
* @var string
*/
public string $transactionUid;

/**
* @var string
*/
public string $agencyNumber;

public function __construct(
string $accountNumber,
string $accountType,
string $agencyNumber,
string $routingNumber,
string $balance,
DateTime $balanceDate,
string $transactionUid,
Statement $statement,
)
{
$this->accountNumber = $accountNumber;
$this->accountType = $accountType;
$this->agencyNumber = $agencyNumber;
$this->routingNumber = $routingNumber;
$this->balance = $balance;
$this->balanceDate = $balanceDate;
$this->transactionUid = $transactionUid;
$this->statement = $statement;
}
}
22 changes: 22 additions & 0 deletions src/Institute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Endeken\OFX;

class Institute
{
/**
* @var string The ID of the institute
*/
public string $id;

/**
* @var string This variable stores the institute name.
*/
public string $name;

public function __construct(string $id, string $name)
{
$this->id = $id;
$this->name = $name;
}
}
Loading

0 comments on commit f7b9e25

Please sign in to comment.