11<?php
2- declare (strict_types = 1 );
2+
3+ declare (strict_types=1 );
34
45namespace Forensic \FeedParser \FeedItems ;
56
@@ -17,27 +18,27 @@ class BaseFeedItem
1718
1819 /**
1920 * feed item type
20- */
21+ */
2122 protected $ _type = null ;
2223
2324 /**
2425 * feed item id
25- */
26+ */
2627 protected $ _id = '' ;
2728
2829 /**
2930 * feed item title
30- */
31+ */
3132 protected $ _title = '' ;
3233
3334 /**
3435 * url link to feed item's homepage
35- */
36+ */
3637 protected $ _link = '' ;
3738
3839 /**
3940 * feed item content
40- */
41+ */
4142 protected $ _content = '' ;
4243
4344 /**
@@ -47,7 +48,7 @@ class BaseFeedItem
4748
4849 /**
4950 * image associated with the feed item
50- */
51+ */
5152 protected $ _image = [
5253 'src ' => '' , //image src link
5354 'link ' => '' , //url that this image links to, likely the feed item's homepage
@@ -56,7 +57,7 @@ class BaseFeedItem
5657
5758 /**
5859 * media type associated with this item
59- */
60+ */
6061 protected $ _enclosure = [
6162
6263 'type ' => '' , //enclose media type
@@ -73,22 +74,32 @@ class BaseFeedItem
7374
7475 /**
7576 * time string describing when this feed item was last updated
76- */
77+ */
7778 protected $ _lastUpdated = '' ;
7879
80+ /**
81+ * timestamp describing when this feed item was created
82+ */
83+ protected $ _createdAtTimestamp = '' ;
84+
85+ /**
86+ * timestamp describing when this feed item was last updated
87+ */
88+ protected $ _lastUpdatedTimestamp = '' ;
89+
7990 /**
8091 * what category does this feed item belong to
81- */
92+ */
8293 protected $ _category = '' ;
8394
8495 /**
8596 * item's source
86- */
97+ */
8798 protected $ _source = '' ;
8899
89100 /**
90101 * who is the author of this item?
91- */
102+ */
92103 protected $ _author = '' ;
93104
94105 /**
@@ -97,10 +108,14 @@ class BaseFeedItem
97108 *@param DOMElement $item - the feed item node
98109 *@param XPath $xpath - the xpath instance for the feed
99110 *@param array $property_selectors - array of property selector maps
100- */
101- public function __construct (FeedItemTypes $ feed_item_type , DOMElement $ item , XPath $ xpath ,
102- array $ property_selectors , array $ parser_options )
103- {
111+ */
112+ public function __construct (
113+ FeedItemTypes $ feed_item_type ,
114+ DOMElement $ item ,
115+ XPath $ xpath ,
116+ array $ property_selectors ,
117+ array $ parser_options
118+ ) {
104119 $ this ->_type = $ feed_item_type ;
105120
106121 $ xpath ->setContextNode ($ item );
@@ -113,12 +128,11 @@ public function __construct(FeedItemTypes $feed_item_type, DOMElement $item, XPa
113128 *
114129 *@param string $property - the property to retrieve
115130 *@return string|null
116- */
131+ */
117132 public function __get (string $ property )
118133 {
119134 $ this_property = '_ ' . $ property ;
120- if (property_exists ($ this , $ this_property ))
121- {
135+ if (property_exists ($ this , $ this_property )) {
122136 $ value = $ this ->{$ this_property };
123137 if (is_array ($ value ))
124138 return new ParameterBag ($ value );
@@ -132,23 +146,20 @@ public function __get(string $property)
132146 /**
133147 * converts the item to array
134148 *@return array
135- */
149+ */
136150 public function toArray ()
137151 {
138152 $ reflector = new ReflectionClass (get_class ($ this ));
139153 $ props = $ reflector ->getProperties (ReflectionProperty::IS_PROTECTED );
140154
141155 $ result = [];
142156
143- foreach ($ props as $ prop )
144- {
157+ foreach ($ props as $ prop ) {
145158 $ this_property_name = $ prop ->getName ();
146159 $ property_name = substr ($ this_property_name , 1 ); //dont include the underscore
147160 if ($ property_name === 'type ' ) {
148161 $ result [$ property_name ] = $ this ->{$ this_property_name }->value ();
149- }
150-
151- else {
162+ } else {
152163 $ result [$ property_name ] = $ this ->{$ this_property_name };
153164 }
154165 }
@@ -159,9 +170,9 @@ public function toArray()
159170 /**
160171 * convert the feed to json
161172 *@return string
162- */
173+ */
163174 public function toJSON ()
164175 {
165176 return json_encode ($ this ->toArray ());
166177 }
167- }
178+ }
0 commit comments