Skip to content

Commit

Permalink
Improved code style for some files, Fixed typing for SignOn Entity, r…
Browse files Browse the repository at this point in the history
…emoved unnecessary ext-http dependency
  • Loading branch information
wesleyguirra committed Feb 25, 2024
1 parent 742e80e commit 851222b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
],
"require": {
"ext-simplexml": "*",
"ext-http": "*",
"ext-mbstring": "*",
"ext-libxml": "*"
},
Expand Down
2 changes: 1 addition & 1 deletion src/OFX.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ private static function parseStatement(SimpleXMLElement $xml): Statement
$sic,
$checkNumber,
);
};
}
return new Statement($currency, $transactions, $startDate, $endDate);
}

Expand Down
11 changes: 7 additions & 4 deletions src/OFXUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace Endeken\OFX;

use RuntimeException;
use SimpleXMLElement;

class OFXUtils
{
public static function normalizeOfx(string $ofxContent): string|false|\SimpleXMLElement
public static function normalizeOfx(string $ofxContent): string|false|SimpleXMLElement
{
$ofxContent = str_replace(['\r\n'], '\n', $ofxContent);
$ofxContent = mb_convert_encoding($ofxContent, 'UTF-8', 'ISO-8859-1');
Expand All @@ -25,7 +28,7 @@ public static function normalizeOfx(string $ofxContent): string|false|\SimpleXML
$xml = simplexml_load_string($ofxXml);

if ($errors = libxml_get_errors()) {
throw new \RuntimeException('Failed to parse OFX: ' . var_export($errors, true));
throw new RuntimeException('Failed to parse OFX: ' . var_export($errors, true));
}

return $xml;
Expand Down Expand Up @@ -110,9 +113,9 @@ private static function closeUnclosedXmlTags($line): string
$line,
$matches
)) {
return "<{$matches[1]}>{$matches[2]}</{$matches[1]}>";
return "<$matches[1]>$matches[2]</$matches[1]>";
}
return $line;
}

}
}
10 changes: 5 additions & 5 deletions src/SignOn.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Endeken\OFX;

use DateTimeInterface;
use DateTime;

class SignOn
{
Expand All @@ -12,9 +12,9 @@ class SignOn
public Status $status;

/**
* @var DateTimeInterface
* @var DateTime
*/
public DateTimeInterface $date;
public DateTime $date;

/**
* @var string
Expand All @@ -26,11 +26,11 @@ class SignOn
*/
public Institute $institute;

public function __construct(Status $status, DateTimeInterface $date, string $language, Institute $institute)
public function __construct(Status $status, DateTime $date, string $language, Institute $institute)
{
$this->status = $status;
$this->date = $date;
$this->language = $language;
$this->institute = $institute;
}
}
}
3 changes: 1 addition & 2 deletions src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ public function __construct(
*/
public function typeDescription(): string
{
// Cast SimpleXMLObject to string
$type = (string)$this->type;
$type = $this->type;
return array_key_exists($type, self::$types) ? self::$types[$type] : '';
}
}

0 comments on commit 851222b

Please sign in to comment.