Skip to content

Commit 3709f3a

Browse files
committed
Rename fields of feed and entry
Renamed: title -> name description -> summary text -> content link -> url
1 parent 98b7765 commit 3709f3a

File tree

7 files changed

+38
-38
lines changed

7 files changed

+38
-38
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ class FetchController
5050

5151
/** @var \Inboxly\Receiver\Feed $feed */
5252
foreach ($feeds as $feed) {
53-
dump("Fetched feed: $feed->title");
53+
dump("Fetched feed: $feed->name");
5454

5555
/** @var \Inboxly\Receiver\Entry $entry */
5656
foreach ($feed->entries as $entry) {
57-
dump("Entry in feed: $entry->title");
57+
dump("Entry in feed: $entry->name");
5858
}
5959
}
6060
}

src/Entry.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ class Entry
1313
*/
1414
public function __construct(
1515
public string $externalId,
16-
public ?string $title,
17-
public ?string $description = null,
18-
public ?string $text = null,
19-
public ?string $link = null,
16+
public ?string $name,
17+
public ?string $summary = null,
18+
public ?string $content = null,
19+
public ?string $url = null,
2020
public ?string $image = null,
2121
public ?string $authorName = null,
22-
public ?string $authorLink = null,
22+
public ?string $authorUrl = null,
2323
public ?DateTime $createdAt = null,
2424
public ?DateTime $updatedAt = null,
2525
)

src/Feed.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ class Feed
1515
*/
1616
public function __construct(
1717
public Parameters $parameters,
18-
public ?string $title = null,
19-
public ?string $description = null,
20-
public ?string $link = null,
18+
public ?string $name = null,
19+
public ?string $summary = null,
20+
public ?string $url = null,
2121
public ?string $image = null,
2222
public ?string $authorName = null,
23-
public ?string $authorLink = null,
23+
public ?string $authorUrl = null,
2424
public ?string $language = null,
2525
public ?DateTime $updatedAt = null,
2626
public ?DateTime $nextUpdateAt = null,

src/Sources/Common/CommonCorrector.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ public function __construct(
3232
*/
3333
public function correctFeed(Feed $feed): void
3434
{
35-
$feed->title = $this->processor->process($feed->title, [
35+
$feed->name = $this->processor->process($feed->name, [
3636
RemoveHtml::class,
3737
Limit::with(100, ''),
3838
Trim::class,
3939
]);
4040

41-
$feed->description = $this->processor->process($feed->description, [
41+
$feed->summary = $this->processor->process($feed->summary, [
4242
RemoveHtml::class,
4343
Limit::with(200),
4444
Trim::class,
@@ -52,25 +52,25 @@ public function correctFeed(Feed $feed): void
5252
*/
5353
public function correctEntry(Entry $entry): void
5454
{
55-
if ($entry->description === null) {
56-
$entry->description = $entry->text;
57-
} elseif ($entry->text === null) {
58-
$entry->text = $entry->description;
55+
if ($entry->summary === null) {
56+
$entry->summary = $entry->content;
57+
} elseif ($entry->content === null) {
58+
$entry->content = $entry->summary;
5959
}
6060

61-
$entry->title = $this->processor->process($entry->title, [
61+
$entry->name = $this->processor->process($entry->name, [
6262
RemoveHtml::class,
6363
Limit::with(100, ''),
6464
Trim::class,
6565
]);
6666

67-
$entry->description = $this->processor->process($entry->description, [
67+
$entry->summary = $this->processor->process($entry->summary, [
6868
RemoveHtml::class,
6969
Limit::with(200),
7070
Trim::class,
7171
]);
7272

73-
$entry->text = $this->processor->process($entry->text, [
73+
$entry->content = $this->processor->process($entry->content, [
7474
SanitizeHtml::class,
7575
Trim::class,
7676
]);

src/Sources/Rss/RssCorrector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ public function __construct(
2727
*/
2828
public function correctFeed(Feed $feed): void
2929
{
30-
if (!$feed->description || !$feed->image) {
30+
if (!$feed->summary || !$feed->image) {
3131
$extracted = $this->embed->get($feed->parameters->url);
3232

33-
if (!$feed->description && $extracted->description) {
34-
$feed->description = Str::limit(trim($extracted->description));
33+
if (!$feed->summary && $extracted->description) {
34+
$feed->summary = Str::limit(trim($extracted->description));
3535
}
3636

3737
$feed->image ?: $feed->image = (string)$extracted->favicon;

src/Sources/Rss/RssFetcher.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ protected function mapToFeed(Parameters $parameters, Result $result): Feed
112112

113113
return new Feed(
114114
parameters: $parameters,
115-
title: $feedIoFeed->getTitle(),
116-
description: $feedIoFeed->getDescription(),
117-
link: $feedIoFeed->getLink(),
115+
name: $feedIoFeed->getTitle(),
116+
summary: $feedIoFeed->getDescription(),
117+
url: $feedIoFeed->getLink(),
118118
image: $feedIoFeed->getLogo(),
119119
authorName: $feedIoFeed->getAuthor()?->getName(),
120-
authorLink: $feedIoFeed->getAuthor()?->getUri(),
120+
authorUrl: $feedIoFeed->getAuthor()?->getUri(),
121121
language: $feedIoFeed->getLanguage(),
122122
updatedAt: $feedIoFeed->getLastModified(),
123123
nextUpdateAt: $result->getNextUpdate(5 * 60),
@@ -134,13 +134,13 @@ protected function mapToEntry(ItemInterface $feedIoItem): Entry
134134
{
135135
return new Entry(
136136
externalId: $feedIoItem->getPublicId(),
137-
title: $feedIoItem->getTitle(),
138-
description: $feedIoItem->getSummary(),
139-
text: $feedIoItem->getContent(),
140-
link: $feedIoItem->getLink(),
137+
name: $feedIoItem->getTitle(),
138+
summary: $feedIoItem->getSummary(),
139+
content: $feedIoItem->getContent(),
140+
url: $feedIoItem->getLink(),
141141
image: $this->getEntryImage($feedIoItem),
142142
authorName: $feedIoItem->getAuthor()?->getName(),
143-
authorLink: $feedIoItem->getAuthor()?->getUri(),
143+
authorUrl: $feedIoItem->getAuthor()?->getUri(),
144144
createdAt: $feedIoItem->getLastModified(),
145145
updatedAt: $feedIoItem->getLastModified(),
146146
);

tests/Sources/Common/CommonCorrectorTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ public function is_remove_html_from_entry_title()
2626
// Setup
2727
$corrector = $this->makeCorrector();
2828
$entry = $this->getEntry();
29-
$entry->title = 'Title with <a href="https://example.com">link</a>.';
29+
$entry->name = 'Title with <a href="https://example.com">link</a>.';
3030

3131
// Run
3232
$corrector->correctEntry($entry);
3333

3434
// Asserts
35-
$this->assertSame('Title with link.', $entry->title);
35+
$this->assertSame('Title with link.', $entry->name);
3636
}
3737

3838
/**
@@ -45,13 +45,13 @@ public function is_remove_html_from_entry_description()
4545
// Setup
4646
$corrector = $this->makeCorrector();
4747
$entry = $this->getEntry();
48-
$entry->description = 'Description with <a href="https://example.com">link</a>.';
48+
$entry->summary = 'Description with <a href="https://example.com">link</a>.';
4949

5050
// Run
5151
$corrector->correctEntry($entry);
5252

5353
// Asserts
54-
$this->assertSame('Description with link.', $entry->description);
54+
$this->assertSame('Description with link.', $entry->summary);
5555
}
5656

5757

@@ -65,15 +65,15 @@ public function is_sanitize_html_in_entry_text()
6565
// Setup
6666
$corrector = $this->makeCorrector();
6767
$entry = $this->getEntry();
68-
$entry->text = 'Text with <a href="https://example.com">link</a>.';
68+
$entry->content = 'Text with <a href="https://example.com">link</a>.';
6969

7070
// Run
7171
$corrector->correctEntry($entry);
7272

7373
// Asserts
7474
$this->assertSame(
7575
'<p>Text with <a href="https://example.com" target="_blank" rel="noreferrer noopener">link</a>.</p>',
76-
$entry->text
76+
$entry->content
7777
);
7878
}
7979

0 commit comments

Comments
 (0)