-
Notifications
You must be signed in to change notification settings - Fork 103
Enhance OFX Parser #46
base: master
Are you sure you want to change the base?
Conversation
+1. In mkopinsky@f44df3a I added a unit test/fixture for a oneline OFX file which does include some line breaks, and this PR passed that with no problem. (I also tested with the actual QFX file from Ally Bank, which also passed.) |
I'm glad to hear that, @mkopinsky, I will include your OFX in this PR. Thank you for your feedback. |
lib/OfxParser/Parser.php
Outdated
@@ -52,18 +50,17 @@ public function loadFromString($ofxContent) | |||
} | |||
|
|||
/** | |||
* Detect if the OFX file is on one line. If it is, add newlines automatically. | |||
* Prepare OFX file contents. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put a better description here of what's going on to make it clearer please? Something like:
Normalise newlines by removing and adding newlines only before opening tags
|
||
return $ofxContent; | ||
// clear all new line characters first | ||
$ofxContent = str_replace(["\r", "\n"], '', $ofxContent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, seems unlikely, but possible that there might be other newlines we didn't intend to replace here (for example, maybe a transaction description has a newline that should be kept for whatever reason). We don't have an existing test, but this may be a BC break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
understood
lib/OfxParser/Parser.php
Outdated
$tag = ltrim(substr($line, 1, strpos($line, '>') - 1), '/'); | ||
|
||
// Line is "<SOMETHING>" or "</SOMETHING>" | ||
if ($line == '<' . $tag . '>' || $line == '</' . $tag . '>') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use ===
for equality checks
Nice improvement, thank you @berosoboy - just a couple of changes please as above :) |
Sorry for the delay on this one, there seems to be a conflict - could you take a look please and poke me when resolved? Thanks! |
Fix #34