From 851222ba19f17764841cf78ace6e048a94fdc168 Mon Sep 17 00:00:00 2001
From: Wes Guirra <wes.guirra@endeken.com>
Date: Sun, 25 Feb 2024 18:05:58 -0300
Subject: [PATCH] Improved code style for some files, Fixed typing for SignOn
 Entity, removed unnecessary ext-http dependency

---
 composer.json       |  1 -
 src/OFX.php         |  2 +-
 src/OFXUtils.php    | 11 +++++++----
 src/SignOn.php      | 10 +++++-----
 src/Transaction.php |  3 +--
 5 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/composer.json b/composer.json
index cff16de..4e2d0c7 100644
--- a/composer.json
+++ b/composer.json
@@ -12,7 +12,6 @@
   ],
   "require": {
     "ext-simplexml": "*",
-    "ext-http": "*",
     "ext-mbstring": "*",
     "ext-libxml": "*"
   },
diff --git a/src/OFX.php b/src/OFX.php
index e9de367..8023394 100644
--- a/src/OFX.php
+++ b/src/OFX.php
@@ -201,7 +201,7 @@ private static function parseStatement(SimpleXMLElement $xml): Statement
                 $sic,
                 $checkNumber,
             );
-        };
+        }
         return new Statement($currency, $transactions, $startDate, $endDate);
     }
 
diff --git a/src/OFXUtils.php b/src/OFXUtils.php
index 806eef2..aded4e9 100644
--- a/src/OFXUtils.php
+++ b/src/OFXUtils.php
@@ -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');
@@ -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;
@@ -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;
     }
 
-}
\ No newline at end of file
+}
diff --git a/src/SignOn.php b/src/SignOn.php
index 4bd960a..d54db1c 100644
--- a/src/SignOn.php
+++ b/src/SignOn.php
@@ -2,7 +2,7 @@
 
 namespace Endeken\OFX;
 
-use DateTimeInterface;
+use DateTime;
 
 class SignOn
 {
@@ -12,9 +12,9 @@ class SignOn
     public Status $status;
 
     /**
-     * @var DateTimeInterface
+     * @var DateTime
      */
-    public DateTimeInterface $date;
+    public DateTime $date;
 
     /**
      * @var string
@@ -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;
     }
-}
\ No newline at end of file
+}
diff --git a/src/Transaction.php b/src/Transaction.php
index 8a86b47..ece315a 100644
--- a/src/Transaction.php
+++ b/src/Transaction.php
@@ -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] : '';
     }
 }