Skip to content

Commit a35777f

Browse files
author
Harrison Ifeanyichukwu
committed
feat: create the RSS feed item class, from which all rss feed item instances are created
The class provides the property map xpath expression selectors that is appropriate for rss feed items
1 parent 8c8c515 commit a35777f

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

src/FeedItems/RSSFeedItem.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
declare(strict_types = 1);
3+
4+
namespace Forensic\FeedParser\FeedItems;
5+
6+
use Forensic\FeedParser\Enums\FeedItemTypes;
7+
use Forensic\FeedParser\XPath;
8+
use DOMElement;
9+
10+
class RSSFeedItem extends BaseFeedItem
11+
{
12+
public function __construct(DOMElement $item, XPath $xpath,
13+
bool $remove_styles, bool $remove_scripts)
14+
{
15+
$property_selectors = [
16+
'id' => 'guid',
17+
'title' => 'title',
18+
'link' => 'link',
19+
'content' => 'content:encoded || description',
20+
'source' => 'source',
21+
'enclosure' => [
22+
'type' => 'enclosure/@type',
23+
'url' => 'enclosure/@url',
24+
'length' => 'enclosure/@length'
25+
],
26+
//'image' => { 'src' => '', 'link' => '', 'title' => '' }, // to be parsed specially
27+
'lastUpdated' => 'pubDate',
28+
'author' => 'author || dc:creator',
29+
'category' => 'category'
30+
];
31+
32+
parent::__construct(
33+
new FeedItemTypes(FeedItemTypes::RSS_FEED_ITEM),
34+
$item,
35+
$xpath,
36+
$property_selectors,
37+
$remove_styles,
38+
$remove_scripts
39+
);
40+
}
41+
}

0 commit comments

Comments
 (0)