aboutsummaryrefslogtreecommitdiffstats
path: root/src/Item.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Item.php')
-rw-r--r--src/Item.php162
1 files changed, 85 insertions, 77 deletions
diff --git a/src/Item.php b/src/Item.php
index 61fd35f..f25b50d 100644
--- a/src/Item.php
+++ b/src/Item.php
@@ -1,4 +1,6 @@
<?php
+
+declare(strict_types=1);
/**
* SimplePie
*
@@ -53,7 +55,7 @@ namespace SimplePie;
* @package \SimplePie\SimplePie
* @subpackage API
*/
-class Item
+class Item implements RegistryAware
{
/**
* Parent feed
@@ -102,7 +104,7 @@ class Item
* @since 1.3
* @param \SimplePie\Registry $registry
*/
- public function set_registry(\SimplePie\Registry $registry)
+ public function set_registry(\SimplePie\Registry $registry)/* : void */
{
$this->registry = $registry;
}
@@ -253,9 +255,9 @@ class Item
{
if (!isset($this->data['title'])) {
if ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'title')) {
- $this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
+ $this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_10_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
} elseif ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'title')) {
- $this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
+ $this->data['title'] = $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_03_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
} elseif ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_10, 'title')) {
$this->data['title'] = $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
} elseif ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_090, 'title')) {
@@ -291,10 +293,10 @@ class Item
public function get_description($description_only = false)
{
if (($tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'summary')) &&
- ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', [$tags[0]['attribs']]), $this->get_base($tags[0])))) {
+ ($return = $this->sanitize($tags[0]['data'], $this->registry->call(Misc::class, 'atom_10_construct_type', [$tags[0]['attribs']]), $this->get_base($tags[0])))) {
return $return;
} elseif (($tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'summary')) &&
- ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', [$tags[0]['attribs']]), $this->get_base($tags[0])))) {
+ ($return = $this->sanitize($tags[0]['data'], $this->registry->call(Misc::class, 'atom_03_construct_type', [$tags[0]['attribs']]), $this->get_base($tags[0])))) {
return $return;
} elseif (($tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_10, 'description')) &&
($return = $this->sanitize($tags[0]['data'], \SimplePie\SimplePie::CONSTRUCT_MAYBE_HTML, $this->get_base($tags[0])))) {
@@ -341,10 +343,10 @@ class Item
public function get_content($content_only = false)
{
if (($tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'content')) &&
- ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', [$tags[0]['attribs']]), $this->get_base($tags[0])))) {
+ ($return = $this->sanitize($tags[0]['data'], $this->registry->call(Misc::class, 'atom_10_content_construct_type', [$tags[0]['attribs']]), $this->get_base($tags[0])))) {
return $return;
} elseif (($tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'content')) &&
- ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', [$tags[0]['attribs']]), $this->get_base($tags[0])))) {
+ ($return = $this->sanitize($tags[0]['data'], $this->registry->call(Misc::class, 'atom_03_construct_type', [$tags[0]['attribs']]), $this->get_base($tags[0])))) {
return $return;
} elseif (($tags = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) &&
($return = $this->sanitize($tags[0]['data'], \SimplePie\SimplePie::CONSTRUCT_HTML, $this->get_base($tags[0])))) {
@@ -368,7 +370,13 @@ class Item
{
if (!isset($this->data['thumbnail'])) {
if ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'thumbnail')) {
- $this->data['thumbnail'] = $return[0]['attribs'][''];
+ $thumbnail = $return[0]['attribs'][''];
+ if (empty($thumbnail['url'])) {
+ $this->data['thumbnail'] = null;
+ } else {
+ $thumbnail['url'] = $this->sanitize($thumbnail['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($return[0]));
+ $this->data['thumbnail'] = $thumbnail;
+ }
} else {
$this->data['thumbnail'] = null;
}
@@ -419,7 +427,7 @@ class Item
if (isset($category['attribs']['']['label'])) {
$label = $this->sanitize($category['attribs']['']['label'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $categories[] = $this->registry->create('Category', [$term, $scheme, $label, $type]);
+ $categories[] = $this->registry->create(Category::class, [$term, $scheme, $label, $type]);
}
foreach ((array) $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, $type) as $category) {
// This is really the label, but keep this as the term also for BC.
@@ -430,15 +438,15 @@ class Item
} else {
$scheme = null;
}
- $categories[] = $this->registry->create('Category', [$term, $scheme, null, $type]);
+ $categories[] = $this->registry->create(Category::class, [$term, $scheme, null, $type]);
}
$type = 'subject';
foreach ((array) $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, $type) as $category) {
- $categories[] = $this->registry->create('Category', [$this->sanitize($category['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null, $type]);
+ $categories[] = $this->registry->create(Category::class, [$this->sanitize($category['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null, $type]);
}
foreach ((array) $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, $type) as $category) {
- $categories[] = $this->registry->create('Category', [$this->sanitize($category['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null, $type]);
+ $categories[] = $this->registry->create(Category::class, [$this->sanitize($category['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null, $type]);
}
if (!empty($categories)) {
@@ -507,7 +515,7 @@ class Item
$email = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
if ($name !== null || $email !== null || $uri !== null) {
- $contributors[] = $this->registry->create('Author', [$name, $uri, $email]);
+ $contributors[] = $this->registry->create(Author::class, [$name, $uri, $email]);
}
}
foreach ((array) $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'contributor') as $contributor) {
@@ -524,7 +532,7 @@ class Item
$email = $this->sanitize($contributor['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
if ($name !== null || $email !== null || $url !== null) {
- $contributors[] = $this->registry->create('Author', [$name, $url, $email]);
+ $contributors[] = $this->registry->create(Author::class, [$name, $url, $email]);
}
}
@@ -560,7 +568,7 @@ class Item
$email = $this->sanitize($author['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_10]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
if ($name !== null || $email !== null || $uri !== null) {
- $authors[] = $this->registry->create('Author', [$name, $uri, $email]);
+ $authors[] = $this->registry->create(Author::class, [$name, $uri, $email]);
}
}
if ($author = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_03, 'author')) {
@@ -577,20 +585,20 @@ class Item
$email = $this->sanitize($author[0]['child'][\SimplePie\SimplePie::NAMESPACE_ATOM_03]['email'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
if ($name !== null || $email !== null || $url !== null) {
- $authors[] = $this->registry->create('Author', [$name, $url, $email]);
+ $authors[] = $this->registry->create(Author::class, [$name, $url, $email]);
}
}
if ($author = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'author')) {
- $authors[] = $this->registry->create('Author', [null, null, $this->sanitize($author[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT)]);
+ $authors[] = $this->registry->create(Author::class, [null, null, $this->sanitize($author[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT)]);
}
foreach ((array) $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'creator') as $author) {
- $authors[] = $this->registry->create('Author', [$this->sanitize($author['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
+ $authors[] = $this->registry->create(Author::class, [$this->sanitize($author['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
}
foreach ((array) $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'creator') as $author) {
- $authors[] = $this->registry->create('Author', [$this->sanitize($author['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
+ $authors[] = $this->registry->create(Author::class, [$this->sanitize($author['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
}
foreach ((array) $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'author') as $author) {
- $authors[] = $this->registry->create('Author', [$this->sanitize($author['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
+ $authors[] = $this->registry->create(Author::class, [$this->sanitize($author['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT), null, null]);
}
if (!empty($authors)) {
@@ -615,7 +623,7 @@ class Item
public function get_copyright()
{
if ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'rights')) {
- return $this->sanitize($return[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
+ return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_10_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
} elseif ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_DC_11, 'rights')) {
return $this->sanitize($return[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
} elseif ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_DC_10, 'rights')) {
@@ -661,8 +669,8 @@ class Item
}
if (!empty($this->data['date']['raw'])) {
- $parser = $this->registry->call('Parse_Date', 'get');
- $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']);
+ $parser = $this->registry->call(Parse\Date::class, 'get');
+ $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']) ?: null;
} else {
$this->data['date'] = null;
}
@@ -703,8 +711,8 @@ class Item
}
if (!empty($this->data['updated']['raw'])) {
- $parser = $this->registry->call('Parse_Date', 'get');
- $this->data['updated']['parsed'] = $parser->parse($this->data['updated']['raw']);
+ $parser = $this->registry->call(Parse\Date::class, 'get');
+ $this->data['updated']['parsed'] = $parser->parse($this->data['updated']['raw']) ?: null;
} else {
$this->data['updated'] = null;
}
@@ -867,7 +875,7 @@ class Item
$keys = array_keys($this->data['links']);
foreach ($keys as $key) {
- if ($this->registry->call('Misc', 'is_isegment_nz_nc', [$key])) {
+ if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) {
if (isset($this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key])) {
$this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key]);
$this->data['links'][$key] =& $this->data['links'][\SimplePie\SimplePie::IANA_LINK_RELATIONS_REGISTRY . $key];
@@ -967,7 +975,7 @@ class Item
if (isset($caption['data'])) {
$caption_text = $this->sanitize($caption['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $captions_parent[] = $this->registry->create('Caption', [$caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text]);
+ $captions_parent[] = $this->registry->create(Caption::class, [$caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text]);
}
} elseif ($captions = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'text')) {
foreach ($captions as $caption) {
@@ -991,7 +999,7 @@ class Item
if (isset($caption['data'])) {
$caption_text = $this->sanitize($caption['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $captions_parent[] = $this->registry->create('Caption', [$caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text]);
+ $captions_parent[] = $this->registry->create(Caption::class, [$caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text]);
}
}
if (is_array($captions_parent)) {
@@ -1014,7 +1022,7 @@ class Item
if (isset($category['attribs']['']['label'])) {
$label = $this->sanitize($category['attribs']['']['label'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $categories_parent[] = $this->registry->create('Category', [$term, $scheme, $label]);
+ $categories_parent[] = $this->registry->create(Category::class, [$term, $scheme, $label]);
}
foreach ((array) $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'category') as $category) {
$term = null;
@@ -1031,7 +1039,7 @@ class Item
if (isset($category['attribs']['']['label'])) {
$label = $this->sanitize($category['attribs']['']['label'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $categories_parent[] = $this->registry->create('Category', [$term, $scheme, $label]);
+ $categories_parent[] = $this->registry->create(Category::class, [$term, $scheme, $label]);
}
foreach ((array) $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'category') as $category) {
$term = null;
@@ -1040,14 +1048,14 @@ class Item
if (isset($category['attribs']['']['text'])) {
$label = $this->sanitize($category['attribs']['']['text'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $categories_parent[] = $this->registry->create('Category', [$term, $scheme, $label]);
+ $categories_parent[] = $this->registry->create(Category::class, [$term, $scheme, $label]);
if (isset($category['child'][\SimplePie\SimplePie::NAMESPACE_ITUNES]['category'])) {
foreach ((array) $category['child'][\SimplePie\SimplePie::NAMESPACE_ITUNES]['category'] as $subcategory) {
if (isset($subcategory['attribs']['']['text'])) {
$label = $this->sanitize($subcategory['attribs']['']['text'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $categories_parent[] = $this->registry->create('Category', [$term, $scheme, $label]);
+ $categories_parent[] = $this->registry->create(Category::class, [$term, $scheme, $label]);
}
}
}
@@ -1065,7 +1073,7 @@ class Item
if (isset($copyright[0]['data'])) {
$copyright_label = $this->sanitize($copyright[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $copyrights_parent = $this->registry->create('Copyright', [$copyright_url, $copyright_label]);
+ $copyrights_parent = $this->registry->create(Copyright::class, [$copyright_url, $copyright_label]);
} elseif ($copyright = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'copyright')) {
$copyright_url = null;
$copyright_label = null;
@@ -1075,7 +1083,7 @@ class Item
if (isset($copyright[0]['data'])) {
$copyright_label = $this->sanitize($copyright[0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $copyrights_parent = $this->registry->create('Copyright', [$copyright_url, $copyright_label]);
+ $copyrights_parent = $this->registry->create(Copyright::class, [$copyright_url, $copyright_label]);
}
// CREDITS
@@ -1095,7 +1103,7 @@ class Item
if (isset($credit['data'])) {
$credit_name = $this->sanitize($credit['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $credits_parent[] = $this->registry->create('Credit', [$credit_role, $credit_scheme, $credit_name]);
+ $credits_parent[] = $this->registry->create(Credit::class, [$credit_role, $credit_scheme, $credit_name]);
}
} elseif ($credits = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'credit')) {
foreach ($credits as $credit) {
@@ -1113,7 +1121,7 @@ class Item
if (isset($credit['data'])) {
$credit_name = $this->sanitize($credit['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $credits_parent[] = $this->registry->create('Credit', [$credit_role, $credit_scheme, $credit_name]);
+ $credits_parent[] = $this->registry->create(Credit::class, [$credit_role, $credit_scheme, $credit_name]);
}
}
if (is_array($credits_parent)) {
@@ -1250,7 +1258,7 @@ class Item
if (isset($rating['data'])) {
$rating_value = $this->sanitize($rating['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $ratings_parent[] = $this->registry->create('Rating', [$rating_scheme, $rating_value]);
+ $ratings_parent[] = $this->registry->create(Rating::class, [$rating_scheme, $rating_value]);
}
} elseif ($ratings = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'explicit')) {
foreach ($ratings as $rating) {
@@ -1259,7 +1267,7 @@ class Item
if (isset($rating['data'])) {
$rating_value = $this->sanitize($rating['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $ratings_parent[] = $this->registry->create('Rating', [$rating_scheme, $rating_value]);
+ $ratings_parent[] = $this->registry->create(Rating::class, [$rating_scheme, $rating_value]);
}
} elseif ($ratings = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'rating')) {
foreach ($ratings as $rating) {
@@ -1273,7 +1281,7 @@ class Item
if (isset($rating['data'])) {
$rating_value = $this->sanitize($rating['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $ratings_parent[] = $this->registry->create('Rating', [$rating_scheme, $rating_value]);
+ $ratings_parent[] = $this->registry->create(Rating::class, [$rating_scheme, $rating_value]);
}
} elseif ($ratings = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'explicit')) {
foreach ($ratings as $rating) {
@@ -1282,7 +1290,7 @@ class Item
if (isset($rating['data'])) {
$rating_value = $this->sanitize($rating['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $ratings_parent[] = $this->registry->create('Rating', [$rating_scheme, $rating_value]);
+ $ratings_parent[] = $this->registry->create(Rating::class, [$rating_scheme, $rating_value]);
}
}
if (is_array($ratings_parent)) {
@@ -1304,7 +1312,7 @@ class Item
if (isset($restriction['data'])) {
$restriction_value = $this->sanitize($restriction['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $restrictions_parent[] = $this->registry->create('Restriction', [$restriction_relationship, $restriction_type, $restriction_value]);
+ $restrictions_parent[] = $this->registry->create(Restriction::class, [$restriction_relationship, $restriction_type, $restriction_value]);
}
} elseif ($restrictions = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'block')) {
foreach ($restrictions as $restriction) {
@@ -1314,7 +1322,7 @@ class Item
if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') {
$restriction_relationship = 'deny';
}
- $restrictions_parent[] = $this->registry->create('Restriction', [$restriction_relationship, $restriction_type, $restriction_value]);
+ $restrictions_parent[] = $this->registry->create(Restriction::class, [$restriction_relationship, $restriction_type, $restriction_value]);
}
} elseif ($restrictions = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'restriction')) {
foreach ($restrictions as $restriction) {
@@ -1330,7 +1338,7 @@ class Item
if (isset($restriction['data'])) {
$restriction_value = $this->sanitize($restriction['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $restrictions_parent[] = $this->registry->create('Restriction', [$restriction_relationship, $restriction_type, $restriction_value]);
+ $restrictions_parent[] = $this->registry->create(Restriction::class, [$restriction_relationship, $restriction_type, $restriction_value]);
}
} elseif ($restrictions = $parent->get_channel_tags(\SimplePie\SimplePie::NAMESPACE_ITUNES, 'block')) {
foreach ($restrictions as $restriction) {
@@ -1340,7 +1348,7 @@ class Item
if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') {
$restriction_relationship = 'deny';
}
- $restrictions_parent[] = $this->registry->create('Restriction', [$restriction_relationship, $restriction_type, $restriction_value]);
+ $restrictions_parent[] = $this->registry->create(Restriction::class, [$restriction_relationship, $restriction_type, $restriction_value]);
}
}
if (is_array($restrictions_parent)) {
@@ -1510,7 +1518,7 @@ class Item
if (isset($caption['data'])) {
$caption_text = $this->sanitize($caption['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $captions[] = $this->registry->create('Caption', [$caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text]);
+ $captions[] = $this->registry->create(Caption::class, [$caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text]);
}
if (is_array($captions)) {
$captions = array_values(array_unique($captions));
@@ -1537,7 +1545,7 @@ class Item
if (isset($caption['data'])) {
$caption_text = $this->sanitize($caption['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $captions[] = $this->registry->create('Caption', [$caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text]);
+ $captions[] = $this->registry->create(Caption::class, [$caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text]);
}
if (is_array($captions)) {
$captions = array_values(array_unique($captions));
@@ -1563,7 +1571,7 @@ class Item
if (isset($category['attribs']['']['label'])) {
$label = $this->sanitize($category['attribs']['']['label'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $categories[] = $this->registry->create('Category', [$term, $scheme, $label]);
+ $categories[] = $this->registry->create(Category::class, [$term, $scheme, $label]);
}
}
if (isset($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['category'])) {
@@ -1582,7 +1590,7 @@ class Item
if (isset($category['attribs']['']['label'])) {
$label = $this->sanitize($category['attribs']['']['label'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $categories[] = $this->registry->create('Category', [$term, $scheme, $label]);
+ $categories[] = $this->registry->create(Category::class, [$term, $scheme, $label]);
}
}
if (is_array($categories) && is_array($categories_parent)) {
@@ -1603,7 +1611,7 @@ class Item
if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['copyright'][0]['data'])) {
$copyright_label = $this->sanitize($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['copyright'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $copyrights = $this->registry->create('Copyright', [$copyright_url, $copyright_label]);
+ $copyrights = $this->registry->create(Copyright::class, [$copyright_url, $copyright_label]);
} elseif (isset($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['copyright'])) {
$copyright_url = null;
$copyright_label = null;
@@ -1613,7 +1621,7 @@ class Item
if (isset($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['copyright'][0]['data'])) {
$copyright_label = $this->sanitize($group['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['copyright'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $copyrights = $this->registry->create('Copyright', [$copyright_url, $copyright_label]);
+ $copyrights = $this->registry->create(Copyright::class, [$copyright_url, $copyright_label]);
} else {
$copyrights = $copyrights_parent;
}
@@ -1635,7 +1643,7 @@ class Item
if (isset($credit['data'])) {
$credit_name = $this->sanitize($credit['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $credits[] = $this->registry->create('Credit', [$credit_role, $credit_scheme, $credit_name]);
+ $credits[] = $this->registry->create(Credit::class, [$credit_role, $credit_scheme, $credit_name]);
}
if (is_array($credits)) {
$credits = array_values(array_unique($credits));
@@ -1656,7 +1664,7 @@ class Item
if (isset($credit['data'])) {
$credit_name = $this->sanitize($credit['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $credits[] = $this->registry->create('Credit', [$credit_role, $credit_scheme, $credit_name]);
+ $credits[] = $this->registry->create(Credit::class, [$credit_role, $credit_scheme, $credit_name]);
}
if (is_array($credits)) {
$credits = array_values(array_unique($credits));
@@ -1762,7 +1770,7 @@ class Item
if (isset($rating['data'])) {
$rating_value = $this->sanitize($rating['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $ratings[] = $this->registry->create('Rating', [$rating_scheme, $rating_value]);
+ $ratings[] = $this->registry->create(Rating::class, [$rating_scheme, $rating_value]);
}
if (is_array($ratings)) {
$ratings = array_values(array_unique($ratings));
@@ -1779,7 +1787,7 @@ class Item
if (isset($rating['data'])) {
$rating_value = $this->sanitize($rating['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $ratings[] = $this->registry->create('Rating', [$rating_scheme, $rating_value]);
+ $ratings[] = $this->registry->create(Rating::class, [$rating_scheme, $rating_value]);
}
if (is_array($ratings)) {
$ratings = array_values(array_unique($ratings));
@@ -1803,7 +1811,7 @@ class Item
if (isset($restriction['data'])) {
$restriction_value = $this->sanitize($restriction['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $restrictions[] = $this->registry->create('Restriction', [$restriction_relationship, $restriction_type, $restriction_value]);
+ $restrictions[] = $this->registry->create(Restriction::class, [$restriction_relationship, $restriction_type, $restriction_value]);
}
if (is_array($restrictions)) {
$restrictions = array_values(array_unique($restrictions));
@@ -1822,7 +1830,7 @@ class Item
if (isset($restriction['data'])) {
$restriction_value = $this->sanitize($restriction['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $restrictions[] = $this->registry->create('Restriction', [$restriction_relationship, $restriction_type, $restriction_value]);
+ $restrictions[] = $this->registry->create(Restriction::class, [$restriction_relationship, $restriction_type, $restriction_value]);
}
if (is_array($restrictions)) {
$restrictions = array_values(array_unique($restrictions));
@@ -1859,7 +1867,7 @@ class Item
$title = $title_parent;
}
- $this->data['enclosures'][] = $this->registry->create('Enclosure', [$url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width]);
+ $this->data['enclosures'][] = $this->registry->create(Enclosure::class, [$url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width]);
}
}
}
@@ -1966,7 +1974,7 @@ class Item
if (isset($caption['data'])) {
$caption_text = $this->sanitize($caption['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $captions[] = $this->registry->create('Caption', [$caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text]);
+ $captions[] = $this->registry->create(Caption::class, [$caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text]);
}
if (is_array($captions)) {
$captions = array_values(array_unique($captions));
@@ -1992,7 +2000,7 @@ class Item
if (isset($category['attribs']['']['label'])) {
$label = $this->sanitize($category['attribs']['']['label'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $categories[] = $this->registry->create('Category', [$term, $scheme, $label]);
+ $categories[] = $this->registry->create(Category::class, [$term, $scheme, $label]);
}
}
if (is_array($categories) && is_array($categories_parent)) {
@@ -2015,7 +2023,7 @@ class Item
if (isset($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['copyright'][0]['data'])) {
$copyright_label = $this->sanitize($content['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['copyright'][0]['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $copyrights = $this->registry->create('Copyright', [$copyright_url, $copyright_label]);
+ $copyrights = $this->registry->create(Copyright::class, [$copyright_url, $copyright_label]);
} else {
$copyrights = $copyrights_parent;
}
@@ -2037,7 +2045,7 @@ class Item
if (isset($credit['data'])) {
$credit_name = $this->sanitize($credit['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $credits[] = $this->registry->create('Credit', [$credit_role, $credit_scheme, $credit_name]);
+ $credits[] = $this->registry->create(Credit::class, [$credit_role, $credit_scheme, $credit_name]);
}
if (is_array($credits)) {
$credits = array_values(array_unique($credits));
@@ -2113,7 +2121,7 @@ class Item
if (isset($rating['data'])) {
$rating_value = $this->sanitize($rating['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $ratings[] = $this->registry->create('Rating', [$rating_scheme, $rating_value]);
+ $ratings[] = $this->registry->create(Rating::class, [$rating_scheme, $rating_value]);
}
if (is_array($ratings)) {
$ratings = array_values(array_unique($ratings));
@@ -2137,7 +2145,7 @@ class Item
if (isset($restriction['data'])) {
$restriction_value = $this->sanitize($restriction['data'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- $restrictions[] = $this->registry->create('Restriction', [$restriction_relationship, $restriction_type, $restriction_value]);
+ $restrictions[] = $this->registry->create(Restriction::class, [$restriction_relationship, $restriction_type, $restriction_value]);
}
if (is_array($restrictions)) {
$restrictions = array_values(array_unique($restrictions));
@@ -2167,7 +2175,7 @@ class Item
$title = $title_parent;
}
- $this->data['enclosures'][] = $this->registry->create('Enclosure', [$url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width]);
+ $this->data['enclosures'][] = $this->registry->create(Enclosure::class, [$url, $type, $length, null, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width]);
}
}
}
@@ -2204,7 +2212,7 @@ class Item
}
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
- $this->data['enclosures'][] = $this->registry->create('Enclosure', [$url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title, $width]);
+ $this->data['enclosures'][] = $this->registry->create(Enclosure::class, [$url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title, $width]);
}
}
@@ -2235,12 +2243,12 @@ class Item
}
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
- $this->data['enclosures'][] = $this->registry->create('Enclosure', [$url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width]);
+ $this->data['enclosures'][] = $this->registry->create(Enclosure::class, [$url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width]);
}
}
- if ($enclosure = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'enclosure')) {
- if (isset($enclosure[0]['attribs']['']['url'])) {
+ foreach ($this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_RSS_20, 'enclosure') ?? [] as $enclosure) {
+ if (isset($enclosure['attribs']['']['url'])) {
// Attributes
$bitrate = null;
$channels = null;
@@ -2257,23 +2265,23 @@ class Item
$url = null;
$width = null;
- $url = $this->sanitize($enclosure[0]['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($enclosure[0]));
+ $url = $this->sanitize($enclosure['attribs']['']['url'], \SimplePie\SimplePie::CONSTRUCT_IRI, $this->get_base($enclosure));
$url = $this->feed->sanitize->https_url($url);
- if (isset($enclosure[0]['attribs']['']['type'])) {
- $type = $this->sanitize($enclosure[0]['attribs']['']['type'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
+ if (isset($enclosure['attribs']['']['type'])) {
+ $type = $this->sanitize($enclosure['attribs']['']['type'], \SimplePie\SimplePie::CONSTRUCT_TEXT);
}
- if (isset($enclosure[0]['attribs']['']['length'])) {
- $length = intval($enclosure[0]['attribs']['']['length']);
+ if (isset($enclosure['attribs']['']['length'])) {
+ $length = intval($enclosure['attribs']['']['length']);
}
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
- $this->data['enclosures'][] = $this->registry->create('Enclosure', [$url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width]);
+ $this->data['enclosures'][] = $this->registry->create(Enclosure::class, [$url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width]);
}
}
if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) {
// Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor
- $this->data['enclosures'][] = $this->registry->create('Enclosure', [$url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width]);
+ $this->data['enclosures'][] = $this->registry->create(Enclosure::class, [$url, $type, $length, null, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width]);
}
$this->data['enclosures'] = array_values(array_unique($this->data['enclosures']));
@@ -2342,7 +2350,7 @@ class Item
public function get_source()
{
if ($return = $this->get_item_tags(\SimplePie\SimplePie::NAMESPACE_ATOM_10, 'source')) {
- return $this->registry->create('Source', [$this, $return[0]]);
+ return $this->registry->create(Source::class, [$this, $return[0]]);
}
return null;