From 77665b25ce0745f55197e4e4f42b7a703f367c36 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Fri, 28 Feb 2020 17:28:03 -0500 Subject: [PATCH] Minor corrections --- lib/Parser/JSON/Entry.php | 3 +-- lib/Parser/XML/Feed.php | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/Parser/JSON/Entry.php b/lib/Parser/JSON/Entry.php index 99e500f..ef5bf2a 100644 --- a/lib/Parser/JSON/Entry.php +++ b/lib/Parser/JSON/Entry.php @@ -83,7 +83,7 @@ class Entry implements \JKingWeb\Lax\Parser\Entry { } else { $neg = false; } - while ($exp > 0) { + while ($exp-- > 0) { if ($mul && $dec) { $int[] = array_shift($dec); } elseif ($mul) { @@ -93,7 +93,6 @@ class Entry implements \JKingWeb\Lax\Parser\Entry { } else { array_unshift($dec, "0"); } - $exp--; } return ($neg ? "-" : "") . ($int ? implode("", $int) : "0") . ($dec ? ("." . rtrim(implode("", $dec), "0")) : ""); } diff --git a/lib/Parser/XML/Feed.php b/lib/Parser/XML/Feed.php index 31f4187..d8c41ce 100644 --- a/lib/Parser/XML/Feed.php +++ b/lib/Parser/XML/Feed.php @@ -8,6 +8,7 @@ namespace JKingWeb\Lax\Parser\XML; use JKingWeb\Lax\Person\Collection as PersonCollection; use JKingWeb\Lax\Category\Collection as CategoryCollection; +use JKingWeb\Lax\Feed as FeedStruct; use JKingWeb\Lax\Date; use JKingWeb\Lax\Text; @@ -57,7 +58,8 @@ class Feed implements \JKingWeb\Lax\Parser\Feed { } /** Parses the feed to extract sundry metadata */ - public function parse(\JKingWeb\Lax\Feed $feed): \JKingWeb\Lax\Feed { + public function parse(FeedStruct $feed = null): FeedStruct { + $feed = $feed ?? new FeedStruct; $feed->id = $this->getId(); $feed->url = $this->getUrl(); $feed->link = $this->getLink(); @@ -66,7 +68,7 @@ class Feed implements \JKingWeb\Lax\Parser\Feed { $feed->people = $this->getPeople(); $feed->author = $this->people->primary(); $feed->dateModified = $this->getDateModified(); - $feed->entries = $this->getEntries(); + $feed->entries = $this->getEntries($feed); // do a second pass on missing data we'd rather fill in $feed->link = strlen($this->link) ? $this->link : $this->url; $feed->title = strlen($this->title) ? $this->title : $this->link; @@ -124,7 +126,7 @@ class Feed implements \JKingWeb\Lax\Parser\Feed { } /** General function to fetch the entries of a feed */ - public function getEntries(): array { + public function getEntries(FeedStruct $feed = null): array { return $this->getEntriesAtom() ?? $this->getEntriesRss1() ?? $this->getEntriesRss2() ?? []; } }