Skip to content

Commit 006a684

Browse files
author
Harrison Ifeanyichukwu
committed
feat: Use php magic __get method to simply property accessibility
1 parent 108317c commit 006a684

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/FeedItems/BaseFeedItem.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ public function __construct(FeedItemTypes $feed_item_type, DOMElement $item, XPa
9595
$this->parse($xpath, $property_selectors, $remove_styles, $remove_scripts);
9696
}
9797

98+
/**
99+
*
100+
*@param string $property - the property to retrieve
101+
*@return string|null
102+
*/
98103
public function __get(string $property)
99104
{
100105
$this_property = '_' . $property;

src/Feeds/BaseFeed.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,13 @@ public function __construct(FeedTypes $feed_type, string $default_lang, XPath $x
121121
for ($i = 0, $len = $items->length; $i < $len; $i++)
122122
$this->_items[] = new $item_class($items->item($i), $xpath, $remove_styles, $remove_scripts);
123123
}
124+
125+
public function __get(string $property)
126+
{
127+
$this_property = '_' . $property;
128+
if (property_exists($this, $this_property))
129+
return $this->{$this_property};
130+
else
131+
return null;
132+
}
124133
}

0 commit comments

Comments
 (0)