-
Notifications
You must be signed in to change notification settings - Fork 0
Fix missing item date and description #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,16 +12,16 @@ class FeedItem | |
| public ?Feed $feed = null; | ||
| public ?string $title = null; | ||
| public ?string $link = null; | ||
| public ?string $description = null; | ||
| public string $description = ''; | ||
| public array $categories = []; | ||
| public ?string $creator = null; | ||
| public ?string $image = null; | ||
| public ?DateTime $date = null; | ||
|
|
||
| public function compareDate(FeedItem $other): int | ||
| { | ||
| $ad = $this->date ?? new DateTime('NOW'); | ||
| $bd = $other->date ?? new DateTime('NOW'); | ||
| $ad = $this->date ?? new DateTime('@0'); | ||
| $bd = $other->date ?? new DateTime('@0'); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is actually no need to create DateTime objects here at all. Simply check if one of the elements is null before trying to compare. |
||
|
|
||
| if ($ad == $bd) { | ||
| return 0; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,7 +103,7 @@ protected function getCategoriesElement(): ?BaseHtmlElement | |
|
|
||
| protected function getContentElement(): ?BaseHtmlElement | ||
| { | ||
| $text = $this->item->description; | ||
| $text = $this->item->description ?? ''; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Description was defined as non-null in the same PR |
||
| $description = new FeedContent($text); | ||
|
|
||
| return HtmlElement::create( | ||
|
|
@@ -122,7 +122,10 @@ protected function getLink(): ?string | |
|
|
||
| protected function getDate(): BaseHtmlElement | ||
| { | ||
| return (new TimeAgo($this->item->date->getTimestamp())); | ||
| $d = $this->item->date; | ||
| $ts = $this->item->date !== null ? $this->item->date->getTimestamp() : 0; | ||
|
|
||
| return (new TimeAgo($ts)); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Superfluous brackets |
||
| } | ||
|
|
||
| protected function assembleHeader(): BaseHtmlElement | ||
|
|
||
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.
Isn't null better than a sentinel value?