Article
in package
Article entity representing an RSS feed item (feed_links table).
Articles are individual items fetched from RSS feeds. They can be imported as texts for reading practice.
Tags
Table of Contents
Constants
- STATUS_ARCHIVED = 'archived'
- STATUS_ERROR = 'error'
- STATUS_IMPORTED = 'imported'
- STATUS_NEW = 'new'
- Article status constants.
Properties
- $audio : string
- $date : string
- $description : string
- $feedId : int
- $id : int|null
- $link : string
- $text : string
- $title : string
Methods
- audio() : string
- cleanLink() : string
- Get the clean link (without error marker).
- create() : self
- Create a new article from RSS feed item.
- date() : string
- description() : string
- determineStatus() : string
- Determine article status based on associated text/archived data.
- feedId() : int
- fromDbRecord() : self
- Load from a database record.
- hasAudio() : bool
- Check if this article has audio attached.
- hasError() : bool
- Check if this article has an error (unloadable).
- hasText() : bool
- Check if this article has extracted text.
- id() : int|null
- isNew() : bool
- Check if this is a new (unsaved) article.
- link() : string
- markAsError() : void
- Mark article as error by prefixing link with space.
- resetError() : void
- Reset error status by trimming the link.
- text() : string
- title() : string
- updateText() : void
- Update the extracted text content.
- __construct() : mixed
- Private constructor - use factory methods instead.
- truncate() : string
- Truncate string to max length.
Constants
STATUS_ARCHIVED
public
mixed
STATUS_ARCHIVED
= 'archived'
STATUS_ERROR
public
mixed
STATUS_ERROR
= 'error'
STATUS_IMPORTED
public
mixed
STATUS_IMPORTED
= 'imported'
STATUS_NEW
Article status constants.
public
mixed
STATUS_NEW
= 'new'
Properties
$audio
private
string
$audio
$date
private
string
$date
$description
private
string
$description
$feedId
private
int
$feedId
$id
private
int|null
$id
$link
private
string
$link
$text
private
string
$text
$title
private
string
$title
Methods
audio()
public
audio() : string
Return values
stringcleanLink()
Get the clean link (without error marker).
public
cleanLink() : string
Return values
stringcreate()
Create a new article from RSS feed item.
public
static create(int $feedId, string $title, string $link[, string $description = '' ][, string $date = '' ][, string $audio = '' ][, string $text = '' ]) : self
Parameters
- $feedId : int
-
Feed ID this article belongs to
- $title : string
-
Article title
- $link : string
-
Article URL
- $description : string = ''
-
Article description/summary
- $date : string = ''
-
Publication date (MySQL datetime format)
- $audio : string = ''
-
Audio URL (for podcasts)
- $text : string = ''
-
Extracted article text
Return values
selfdate()
public
date() : string
Return values
stringdescription()
public
description() : string
Return values
stringdetermineStatus()
Determine article status based on associated text/archived data.
public
determineStatus(int|null $textId, int|null $archivedId) : string
Parameters
- $textId : int|null
-
Associated text ID (from LEFT JOIN)
- $archivedId : int|null
-
Associated archived text ID (from LEFT JOIN)
Return values
string —One of STATUS_* constants
feedId()
public
feedId() : int
Return values
intfromDbRecord()
Load from a database record.
public
static fromDbRecord(array<string, mixed> $record) : self
Parameters
- $record : array<string, mixed>
-
Database record
Return values
selfhasAudio()
Check if this article has audio attached.
public
hasAudio() : bool
Return values
boolhasError()
Check if this article has an error (unloadable).
public
hasError() : bool
Return values
boolhasText()
Check if this article has extracted text.
public
hasText() : bool
Return values
boolid()
public
id() : int|null
Return values
int|nullisNew()
Check if this is a new (unsaved) article.
public
isNew() : bool
Return values
boollink()
public
link() : string
Return values
stringmarkAsError()
Mark article as error by prefixing link with space.
public
markAsError() : void
This is a legacy pattern - articles with space-prefixed links are considered "unloadable" and won't be re-fetched.
resetError()
Reset error status by trimming the link.
public
resetError() : void
text()
public
text() : string
Return values
stringtitle()
public
title() : string
Return values
stringupdateText()
Update the extracted text content.
public
updateText(string $text) : void
Parameters
- $text : string
-
New text content
__construct()
Private constructor - use factory methods instead.
private
__construct(int|null $id, int $feedId, string $title, string $link, string $description, string $date, string $audio, string $text) : mixed
Parameters
- $id : int|null
- $feedId : int
- $title : string
- $link : string
- $description : string
- $date : string
- $audio : string
- $text : string
truncate()
Truncate string to max length.
private
static truncate(string $value, int $maxLength) : string
Parameters
- $value : string
-
String to truncate
- $maxLength : int
-
Maximum length