Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/OfxParser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,32 @@ class Parser
* Load an OFX file into this parser by way of a filename
*
* @param string $ofxFile A path that can be loaded with file_get_contents
* @param bool $encode
* @return Ofx
* @throws \Exception
*/
public function loadFromFile($ofxFile)
public function loadFromFile($ofxFile, $encode = true)
{
if (!file_exists($ofxFile)) {
throw new \InvalidArgumentException("File '{$ofxFile}' could not be found");
}

return $this->loadFromString(file_get_contents($ofxFile));
return $this->loadFromString(file_get_contents($ofxFile), $encode);
}

/**
* Load an OFX by directly using the text content
*
* @param string $ofxContent
* @param bool $encode
* @return Ofx
* @throws \Exception
*/
public function loadFromString($ofxContent)
public function loadFromString($ofxContent, $encode = true)
{
$ofxContent = utf8_encode($ofxContent);
if ($encode) {
$ofxContent = utf8_encode($ofxContent);
}
$ofxContent = $this->conditionallyAddNewlines($ofxContent);

$sgmlStart = stripos($ofxContent, '<OFX>');
Expand Down